@@ -515,6 +515,26 @@ def create_blob(self, content, encoding):
515
515
sha = json .get ('sha' )
516
516
return sha
517
517
518
+ @requires_auth
519
+ def create_branch (self , name , sha = None ):
520
+ """Create a branch. Returns False if branch doesn't exist
521
+ or not authorized.
522
+
523
+ :param str branch: (required), the branch to create.
524
+ :param str|commit sha: (optional), the commit to base
525
+ the branch from, otherwise the HEAD commit on
526
+ master will be fetched from the API.
527
+
528
+ :returns: bool -- True if successful, False otherwise
529
+ """
530
+ if isinstance (sha , Commit ):
531
+ sha = sha .sha
532
+ elif not isinstance (sha , basestring ):
533
+ sha = self .commit ("HEAD" ).sha
534
+
535
+ ref = "refs/heads/%s" % name
536
+ return self .create_ref (ref , sha )
537
+
518
538
@requires_auth
519
539
def create_comment (self , body , sha , path = None , position = None , line = 1 ):
520
540
"""Create a comment on a commit.
@@ -1074,6 +1094,18 @@ def delete(self):
1074
1094
"""
1075
1095
return self ._boolean (self ._delete (self ._api ), 204 , 404 )
1076
1096
1097
+ @requires_auth
1098
+ def delete_branch (self , name ):
1099
+ """Delete a branch. Returns False if branch doesn't exist
1100
+ or not authorized.
1101
+
1102
+ :param str branch: (required), the branch to delete.
1103
+
1104
+ :returns: bool -- True if successful, False otherwise
1105
+ """
1106
+ url = self ._build_url ('git/refs/heads' , name , base_url = self ._api )
1107
+ return self ._boolean (self ._delete (url ), 204 , 404 )
1108
+
1077
1109
@requires_auth
1078
1110
def delete_key (self , key_id ):
1079
1111
"""Delete the key with the specified id from your deploy keys list.
0 commit comments