Skip to content
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

Push local branch with --set-upstream #116

Merged
merged 2 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions g3/services/generate/pr/messages/creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def create(self, tone: MessageTone, jira=None, include=None, edit: Optional[int]

title = reviewed_message.split("\n")[1]
description = reviewed_message.split(title)[1]
git.push("origin", git_info.branch, force=True)
git.push("origin", git_info.branch)
self.gh.update_pull_request(pr.number, title, description)
print(f"Successfully updated PR: {pr.html_url}")
else:
Expand All @@ -51,6 +51,6 @@ def create(self, tone: MessageTone, jira=None, include=None, edit: Optional[int]

title = reviewed_message.split("\n")[1]
description = reviewed_message.split(title)[1]
git.push("origin", git_info.branch, force=True)
git.push("origin", git_info.branch)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--force was added so that we can easily override the remote with rebased/amended commits in case of g pr --edit X or g pr on an already pushed branch with the same name in github.

We had discussed setting this in the configs too but defaulting to True would make, again, more sense to me since developers commonly rebase or amend their commits before merging their work to the main branch.

We don't need to disable the force flag to resolve the reported issue, do we?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap we don't need to. Personally I would rather be asked if something is going to be forced in remote but no strong opinion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created this issue so that we support that in the context of v1; let's develop them separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted

pr = self.gh.create_pull_request(title, description)
print(f"Opened PR: {pr.html_url}")
4 changes: 2 additions & 2 deletions g3/services/git/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ def push(remote: str, branch: str, force: bool = False) -> None:
Push the current branch to the remote.
"""
if force:
sh.git("push", remote, "--force", branch)
sh.git("push", "--set-upstream", remote, "--force", branch)
else:
sh.git("push", remote, branch)
sh.git("push", "--set-upstream", remote, branch)
Comment on lines +96 to +98
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍