Skip to content

Commit 5c36af0

Browse files
zacarycgonchik
authored andcommitted
[Bitbucket] Adding ability to fork a repo to a different project (#843)
* Adding new function/functionality to be able to fork a repo to a project that differs from the original source project, which is what th existing functionality is limited to. * Ran black analyzer over code, fixed up the multiline function definition wrap * Fixed up mismatch in parameter name
1 parent a812ee0 commit 5c36af0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

atlassian/bitbucket/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,22 @@ def fork_repository(self, project_key, repository_slug, new_repository_slug):
855855
body["project"] = {"key": project_key}
856856
return self.post(url, data=body)
857857

858+
def fork_repository_new_project(self, project_key, repository_slug, new_project_key, new_repository_slug):
859+
"""
860+
Forks a repository to a separate project.
861+
:param project_key: Origin Project Key
862+
:param repository_slug: Origin repository slug
863+
:param new_project_key: Project Key of target project
864+
:param new_repository_slug: Target Repository slug
865+
:return:
866+
"""
867+
url = self._url_repo(project_key, repository_slug)
868+
body = {}
869+
if new_repository_slug is not None and new_project_key is not None:
870+
body["name"] = new_repository_slug
871+
body["project"] = {"key": new_project_key}
872+
return self.post(url, data=body)
873+
858874
def repo_keys(self, project_key, repo_key, start=0, limit=None, filter_str=None):
859875
"""
860876
Get SSH access keys added to the repository

0 commit comments

Comments
 (0)