Skip to content

Commit

Permalink
Add include_all_branches to create_repo_from_template of `Authent…
Browse files Browse the repository at this point in the history
…icatedUser` and `Organization` (#2871)
  • Loading branch information
janssonoskar committed Jan 15, 2024
1 parent 603896f commit 34c4642
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions github/AuthenticatedUser.py
Expand Up @@ -468,6 +468,7 @@ def create_repo_from_template(
name: str,
repo: Repository,
description: Opt[str] = NotSet,
include_all_branches: Opt[bool] = NotSet,
private: Opt[bool] = NotSet,
) -> Repository:
"""
Expand All @@ -476,12 +477,14 @@ def create_repo_from_template(
assert isinstance(name, str), name
assert isinstance(repo, github.Repository.Repository), repo
assert is_optional(description, str), description
assert is_optional(include_all_branches, bool), include_all_branches
assert is_optional(private, bool), private
post_parameters: dict[str, Any] = NotSet.remove_unset_items(
{
"name": name,
"owner": self.login,
"description": description,
"include_all_branches": include_all_branches,
"private": private,
}
)
Expand Down
10 changes: 9 additions & 1 deletion github/Organization.py
Expand Up @@ -389,6 +389,7 @@ def create_repo_from_template(
name: str,
repo: Repository,
description: Opt[str] = NotSet,
include_all_branches: Opt[bool] = NotSet,
private: Opt[bool] = NotSet,
) -> Repository:
"""self.name
Expand All @@ -397,9 +398,16 @@ def create_repo_from_template(
assert isinstance(name, str), name
assert isinstance(repo, github.Repository.Repository), repo
assert is_optional(description, str), description
assert is_optional(include_all_branches, bool), include_all_branches
assert is_optional(private, bool), private
post_parameters: dict[str, Any] = NotSet.remove_unset_items(
{"name": name, "owner": self.login, "description": description, "private": private}
{
"name": name,
"owner": self.login,
"description": description,
"include_all_branches": include_all_branches,
"private": private,
}
)

headers, data = self._requester.requestJsonAndCheck(
Expand Down
1 change: 1 addition & 0 deletions tests/AuthenticatedUser.py
Expand Up @@ -693,6 +693,7 @@ def testCreateRepoFromTemplateWithAllArguments(self):
"hello-world-docker-action-new",
template_repo,
description=description,
include_all_branches=True,
private=private,
)
self.assertEqual(repo.description, description)
Expand Down
1 change: 1 addition & 0 deletions tests/Organization.py
Expand Up @@ -412,6 +412,7 @@ def testCreateRepoFromTemplateWithAllArguments(self):
"hello-world-docker-action-new",
template_repo,
description=description,
include_all_branches=True,
private=private,
)
self.assertEqual(repo.description, description)
Expand Down
Expand Up @@ -26,7 +26,7 @@ api.github.com
None
/repos/actions/hello-world-docker-action/generate
{'Accept': 'application/vnd.github.v3+json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python', 'Content-Type': 'application/json'}
{"name": "hello-world-docker-action-new", "owner": "jacquev6", "description": "My repo from template", "private": true}
{"name": "hello-world-docker-action-new", "owner": "jacquev6", "description": "My repo from template", "include_all_branches": true, "private": true}
201
[('Server', 'GitHub.com'), ('Date', 'Tue, 11 Feb 2020 19:18:59 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Content-Length', '11794'), ('Status', '201 Created'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4994'), ('X-RateLimit-Reset', '1581452316'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept'), ('ETag', '"7fe9f51a711de4ffab9b930e33e3d875"'), ('X-OAuth-Scopes', 'public_repo, read:org, read:user, user:email'), ('X-Accepted-OAuth-Scopes', ''), ('Location', 'https://api.github.com/repos/jacquev6/hello-world-docker-action-new'), ('X-GitHub-Media-Type', 'github.baptiste-preview; format=json'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '1; mode=block'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('X-GitHub-Request-Id', '3FB4:2492:632B7:FC388:5E42FE21')]
{"id":239844699,"node_id":"MDEwOlJlcG9zaXRvcnkyMzk4NDQ2OTk=","name":"hello-world-docker-action-new","full_name":"jacquev6/hello-world-docker-action-new","owner":{"login":"jacquev6","id":9718970,"node_id":"MDQ6VXNlcjk3MTg5NzA=","avatar_url":"https://avatars2.githubusercontent.com/u/9718970?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},"private":true,"html_url":"https://github.com/jacquev6/hello-world-docker-action-new","description":"My repo from template","fork":false,"url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new","forks_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/forks","keys_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/teams","hooks_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/hooks","issue_events_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/issues/events{/number}","events_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/events","assignees_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/assignees{/user}","branches_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/branches{/branch}","tags_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/tags","blobs_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/git/refs{/sha}","trees_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/statuses/{sha}","languages_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/languages","stargazers_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/stargazers","contributors_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/contributors","subscribers_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/subscribers","subscription_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/subscription","commits_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/commits{/sha}","git_commits_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/git/commits{/sha}","comments_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/comments{/number}","issue_comment_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/issues/comments{/number}","contents_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/contents/{+path}","compare_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/merges","archive_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/downloads","issues_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/issues{/number}","pulls_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/pulls{/number}","milestones_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/milestones{/number}","notifications_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/labels{/name}","releases_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/releases{/id}","deployments_url":"https://api.github.com/repos/jacquev6/hello-world-docker-action-new/deployments","created_at":"2020-02-11T19:18:57Z","updated_at":"2020-02-11T19:18:57Z","pushed_at":"2020-02-11T19:18:59Z","git_url":"git://github.com/jacquev6/hello-world-docker-action-new.git","ssh_url":"git@github.com:jacquev6/hello-world-docker-action-new.git","clone_url":"https://github.com/jacquev6/hello-world-docker-action-new.git","svn_url":"https://github.com/jacquev6/hello-world-docker-action-new","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master","permissions":{"pull":true,"push":true,"admin":true},"is_template":false,"template_repository":{"id":200448202,"node_id":"MDEwOlJlcG9zaXRvcnkyMDA0NDgyMDI=","name":"hello-world-docker-action","full_name":"actions/hello-world-docker-action","owner":{"login":"actions","id":44036562,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0MDM2NTYy","avatar_url":"https://avatars1.githubusercontent.com/u/44036562?v=4","gravatar_id":"","url":"https://api.github.com/users/actions","html_url":"https://github.com/actions","followers_url":"https://api.github.com/users/actions/followers","following_url":"https://api.github.com/users/actions/following{/other_user}","gists_url":"https://api.github.com/users/actions/gists{/gist_id}","starred_url":"https://api.github.com/users/actions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/actions/subscriptions","organizations_url":"https://api.github.com/users/actions/orgs","repos_url":"https://api.github.com/users/actions/repos","events_url":"https://api.github.com/users/actions/events{/privacy}","received_events_url":"https://api.github.com/users/actions/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/actions/hello-world-docker-action","description":"A template to demonstrate how to build a Docker action.","fork":false,"url":"https://api.github.com/repos/actions/hello-world-docker-action","forks_url":"https://api.github.com/repos/actions/hello-world-docker-action/forks","keys_url":"https://api.github.com/repos/actions/hello-world-docker-action/keys{/key_id}","collaborators_url":"https://api.github.com/repos/actions/hello-world-docker-action/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/actions/hello-world-docker-action/teams","hooks_url":"https://api.github.com/repos/actions/hello-world-docker-action/hooks","issue_events_url":"https://api.github.com/repos/actions/hello-world-docker-action/issues/events{/number}","events_url":"https://api.github.com/repos/actions/hello-world-docker-action/events","assignees_url":"https://api.github.com/repos/actions/hello-world-docker-action/assignees{/user}","branches_url":"https://api.github.com/repos/actions/hello-world-docker-action/branches{/branch}","tags_url":"https://api.github.com/repos/actions/hello-world-docker-action/tags","blobs_url":"https://api.github.com/repos/actions/hello-world-docker-action/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/actions/hello-world-docker-action/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/actions/hello-world-docker-action/git/refs{/sha}","trees_url":"https://api.github.com/repos/actions/hello-world-docker-action/git/trees{/sha}","statuses_url":"https://api.github.com/repos/actions/hello-world-docker-action/statuses/{sha}","languages_url":"https://api.github.com/repos/actions/hello-world-docker-action/languages","stargazers_url":"https://api.github.com/repos/actions/hello-world-docker-action/stargazers","contributors_url":"https://api.github.com/repos/actions/hello-world-docker-action/contributors","subscribers_url":"https://api.github.com/repos/actions/hello-world-docker-action/subscribers","subscription_url":"https://api.github.com/repos/actions/hello-world-docker-action/subscription","commits_url":"https://api.github.com/repos/actions/hello-world-docker-action/commits{/sha}","git_commits_url":"https://api.github.com/repos/actions/hello-world-docker-action/git/commits{/sha}","comments_url":"https://api.github.com/repos/actions/hello-world-docker-action/comments{/number}","issue_comment_url":"https://api.github.com/repos/actions/hello-world-docker-action/issues/comments{/number}","contents_url":"https://api.github.com/repos/actions/hello-world-docker-action/contents/{+path}","compare_url":"https://api.github.com/repos/actions/hello-world-docker-action/compare/{base}...{head}","merges_url":"https://api.github.com/repos/actions/hello-world-docker-action/merges","archive_url":"https://api.github.com/repos/actions/hello-world-docker-action/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/actions/hello-world-docker-action/downloads","issues_url":"https://api.github.com/repos/actions/hello-world-docker-action/issues{/number}","pulls_url":"https://api.github.com/repos/actions/hello-world-docker-action/pulls{/number}","milestones_url":"https://api.github.com/repos/actions/hello-world-docker-action/milestones{/number}","notifications_url":"https://api.github.com/repos/actions/hello-world-docker-action/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/actions/hello-world-docker-action/labels{/name}","releases_url":"https://api.github.com/repos/actions/hello-world-docker-action/releases{/id}","deployments_url":"https://api.github.com/repos/actions/hello-world-docker-action/deployments","created_at":"2019-08-04T04:10:12Z","updated_at":"2020-02-07T09:28:27Z","pushed_at":"2020-01-17T19:48:23Z","git_url":"git://github.com/actions/hello-world-docker-action.git","ssh_url":"git@github.com:actions/hello-world-docker-action.git","clone_url":"https://github.com/actions/hello-world-docker-action.git","svn_url":"https://github.com/actions/hello-world-docker-action","homepage":"https://help.github.com/en/articles/creating-a-docker-container-action","size":11,"stargazers_count":26,"watchers_count":26,"language":"Dockerfile","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":30,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":30,"open_issues":1,"watchers":26,"default_branch":"master","permissions":{"pull":true,"push":false,"admin":false},"is_template":true},"subscribers_count":1,"network_count":1}

0 comments on commit 34c4642

Please sign in to comment.