-
Notifications
You must be signed in to change notification settings - Fork 21
feat: added branch flag to deploy command #306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,6 +77,26 @@ def new_branch(self, branch: str) -> None: | |
| except GitError as ex: | ||
| raise GitOpsException(f"Error creating new branch '{branch}'.") from ex | ||
|
|
||
| def checkout(self, branch: str) -> None: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Instead of cloning For example, call This would avoid cloning |
||
| logging.info("Checking out branch: %s", branch) | ||
| repo = self.__get_repo() | ||
| try: | ||
| current_branch = repo.git.branch("--show-current") | ||
| if current_branch == branch: | ||
| return | ||
| repo.git.fetch("origin", f"+refs/heads/{branch}:refs/remotes/origin/{branch}", "--depth=1") | ||
| repo.git.checkout("-B", branch, f"origin/{branch}") | ||
| repo.git.config(f"branch.{branch}.remote", "origin") | ||
| repo.git.config(f"branch.{branch}.merge", f"refs/heads/{branch}") | ||
| except GitError as ex: | ||
| raise GitOpsException(f"Error checking out branch '{branch}'.") from ex | ||
|
|
||
| def checkout_or_create_branch(self, branch: str) -> None: | ||
| if self.__remote_branch_exists(branch): | ||
| self.checkout(branch) | ||
| else: | ||
| self.new_branch(branch) | ||
|
|
||
| def commit( | ||
| self, | ||
| git_user: str, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Mentioning the PR creation here is a bit confusing. I'd mention the branch flag in the PR flag instead.