8000 Merge pull request #364 from ryanpitts/issue-363 · frossie/github3.py@74c4c53 · GitHub
[go: up one dir, main page]

Skip to content

Commit 74c4c53

Browse files
committed
Merge pull request sigmavirus24#364 from ryanpitts/issue-363
allow `branch` argument on update and delete methods for Contents objects
2 parents fc598a2 + 92f5044 commit 74c4c53

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

AUTHORS.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,5 @@ Contributors
8686
- Ryan Weald (@rweald)
8787

8888
- Lars Holm Nielsen (@larshankat)
89+
90+
- Ryan Pitts (@ryanpitts)

github3/repos/contents.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,12 @@ def __ne__(self, other):
9393
return self.sha != other
9494

9595
@requires_auth
96-
def delete(self, message, committer=None, author=None):
96+
def delete(self, message, branch=None, committer=None, author=None):
9797
"""Delete this file.
9898
9999
:param str message: (required), commit message to describe the removal
100+
:param str branch: (optional), branch where the file exists.
101+
Defaults to the default branch of the repository.
100102
:param dict committer: (optional), if no information is given the
101103
authenticated user's information will be used. You must specify
102104
both a name and email.
@@ -109,7 +111,7 @@ def delete(self, message, committer=None, author=None):
109111
"""
110112
json = {}
111113
if message:
112-
data = {'message': message, 'sha': self.sha,
114+
data = {'message': message, 'sha': self.sha, 'branch': branch,
113115
'committer': validate_commmitter(committer),
114116
'author': validate_commmitter(author)}
115117
self._remove_none(data)
@@ -122,11 +124,14 @@ def delete(self, message, committer=None, author=None):
122124
return json
123125

124126
@requires_auth
125-
def update(self, message, content, committer=None, author=None):
127+
def update(self, message, content, branch=None, committer=None,
128+
author=None):
126129
"""Update this file.
127130
128131
:param str message: (required), commit message to describe the update
129132
:param str content: (required), content to update the file with
133+
:param str branch: (optional), branch where the file exists.
134+
Defaults to the default branch of the repository.
130135
:param dict committer: (optional), if no information is given the
131136
authenticated user's information will be used. You must specify
132137
both a name and email.
@@ -145,7 +150,8 @@ def update(self, message, content, committer=None, author=None):
145150
json = None
146151
if message and content:
147152
content = b64encode(content).decode('utf-8')
148-
data = {'message': message, 'content': content, 'sha': self.sha,
153+
data = {'message': message, 'content': content, 'branch': branch,
154+
'sha': self.sha,
149155
'committer': validate_commmitter(committer),
150156
'author': validate_commmitter(author)}
151157
self._remove_none(data)

0 commit comments

Comments
 (0)
0