Skip to content

Commit

Permalink
name and message are not required when generate_release_notes it true
Browse files Browse the repository at this point in the history
  • Loading branch information
heitorpolidoro committed Jan 5, 2024
1 parent 603896f commit b0f9519
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
14 changes: 8 additions & 6 deletions github/Repository.py
Expand Up @@ -1245,8 +1245,8 @@ def create_git_tag_and_release(
def create_git_release(
self,
tag: str,
name: str,
message: str,
name: str = NotSet,

Check failure on line 1248 in github/Repository.py

View workflow job for this annotation

GitHub Actions / mypy

Incompatible default for argument "name" (default has type "_NotSetType", argument has type "str")

Check failure on line 1248 in github/Repository.py

View workflow job for this annotation

GitHub Actions / mypy

Incompatible default for argument "name" (default has type "_NotSetType", argument has type "str")
message: str = NotSet,

Check failure on line 1249 in github/Repository.py

View workflow job for this annotation

GitHub Actions / mypy

Incompatible default for argument "message" (default has type "_NotSetType", argument has type "str")

Check failure on line 1249 in github/Repository.py

View workflow job for this annotation

GitHub Actions / mypy

Incompatible default for argument "message" (default has type "_NotSetType", argument has type "str")
draft: bool = False,
prerelease: bool = False,
generate_release_notes: bool = False,
Expand All @@ -1264,8 +1264,8 @@ def create_git_release(
:rtype: :class:`github.GitRelease.GitRelease`
"""
assert isinstance(tag, str), tag
assert isinstance(name, str), name
assert isinstance(message, str), message
assert is_optional(name, str), name
assert is_optional(message, str), message
assert isinstance(draft, bool), draft
assert isinstance(prerelease, bool), prerelease
assert isinstance(generate_release_notes, bool), generate_release_notes
Expand All @@ -1275,12 +1275,14 @@ def create_git_release(
), target_commitish
post_parameters = {
"tag_name": tag,
"name": name,
"body": message,
"draft": draft,
"prerelease": prerelease,
"generate_release_notes": generate_release_notes,
}
if is_defined(name):
post_parameters["name"] = name
if is_defined(message):
post_parameters["body"] = message
if isinstance(target_commitish, str):
post_parameters["target_commitish"] = target_commitish
elif isinstance(target_commitish, github.Branch.Branch):
Expand Down
@@ -0,0 +1,10 @@
https
POST
api.github.com
None
/repos/jacquev6/PyGithub/releases
{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
{"prerelease": false, "generate_release_notes": true, "tag_name": "vX.Y.Z-by-PyGithub-acctest-release-notes", "draft": false}
201
[('content-length', '1656'), ('x-runtime-rack', '0.601694'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('etag', '"64c4aea05900ae1072ee705caf9b529c"'), ('location', 'https://api.github.com/repos/jacquev6/PyGithub/releases/7636454'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('status', '201 Created'), ('x-ratelimit-remaining', '4951'), ('x-github-media-type', 'github.v3; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', '92E2:1D39A:50FE29C:5DF3D65:59AE9019'), ('date', 'Tue, 05 Sep 2017 11:52:58 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1504614271')]
{"url":"https://api.github.com/repos/jacquev6/PyGithub/releases/7636454","assets_url":"https://api.github.com/repos/jacquev6/PyGithub/releases/7636454/assets","upload_url":"https://uploads.github.com/repos/jacquev6/PyGithub/releases/7636454/assets{?name,label}","html_url":"https://github.com/jacquev6/PyGithub/releases/tag/vX.Y.Z-by-PyGithub-acctest-release-notes","id":7636454,"tag_name":"vX.Y.Z-by-PyGithub-acctest-release-notes","target_commitish":"master","name":"vX.Y.Z: PyGithub acctest-release-notes","draft":false,"author":{"login":"jacquev6","id":3760893,"avatar_url":"https://avatars2.githubusercontent.com/u/3760893?v=4","gravatar_id":"","url":"https://api.github.com/users/jacquev6","html_url":"https://github.com/jacquev6","followers_url":"https://api.github.com/users/jacquev6/followers","following_url":"https://api.github.com/users/jacquev6/following{/other_user}","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","organizations_url":"https://api.github.com/users/jacquev6/orgs","repos_url":"https://api.github.com/users/jacquev6/repos","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","received_events_url":"https://api.github.com/users/jacquev6/received_events","type":"User","site_admin":false},"prerelease":false,"created_at":"2016-10-29T02:39:27Z","published_at":"2017-09-05T11:52:58Z","assets":[],"tarball_url":"https://api.github.com/repos/jacquev6/PyGithub/tarball/vX.Y.Z-by-PyGithub-acctest-release-notes","zipball_url":"https://api.github.com/repos/jacquev6/PyGithub/zipball/vX.Y.Z-by-PyGithub-acctest-release-notes","body":"This release is created by PyGithub"}
9 changes: 9 additions & 0 deletions tests/Repository.py
Expand Up @@ -405,6 +405,15 @@ def testCreateGitRelease(self):
self.assertEqual(release.draft, False)
self.assertEqual(release.prerelease, False)

def testCreateGitReleaseGenerateReleaseNotes(self):
release = self.repo.create_git_release(
"vX.Y.Z-by-PyGithub-acctest-release-notes",
generate_release_notes=True
)
self.assertEqual(release.tag_name, "vX.Y.Z-by-PyGithub-acctest-release-notes")
self.assertEqual(release.draft, False)
self.assertEqual(release.prerelease, False)

def testCreateGitReleaseWithAllArguments(self):
release = self.repo.create_git_release(
"vX.Y.Z-by-PyGithub-acctest2",
Expand Down

0 comments on commit b0f9519

Please sign in to comment.