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

Set upstream on all local branches #219

Merged
merged 2 commits into from
Jan 20, 2025
Merged
Changes from all commits
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
25 changes: 24 additions & 1 deletion installation_and_upgrade/ibex_install_utils/tasks/git_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def checkout_to_release_branch(self) -> None:

try:
subprocess.check_call(f"cd /d {EPICS_PATH} && git fetch", shell=True)
print("Fetched remote")
print("Fetching from remote")
except subprocess.CalledProcessError as e:
print(f"Error fetching remote: {e}")

Expand All @@ -51,6 +51,29 @@ def checkout_to_release_branch(self) -> None:
except subprocess.CalledProcessError as e:
print(f"Error running git status: {e}")

# this sets upstream tracking on all local branches not just current one
try:
subprocess.check_call(
f"cd /d {EPICS_PATH} && FOR /F \"delims=* \" %i IN ('git branch') "
"DO git branch --set-upstream-to=origin/%i %i",
shell=True,
)
Comment on lines +56 to +60
Copy link
Contributor

@Tom-Willemsen Tom-Willemsen Jan 19, 2025

Choose a reason for hiding this comment

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

Isn't this just git config push.autoSetupRemote true or am I missing something?

And if we can't use the git config flag for some reason, is there a reason this loop needs to be in bat rather than using gitpython to loop in python?

Copy link
Member Author

Choose a reason for hiding this comment

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

i think autSetupRemote means you can push without using -u whereas we want to pull here and need to setup where to pull from. Upsteam is more recent, will it let you do a push first (even though there is nothing to push and upsteam is ahead) which would just setup the remote and then allow a pull?

the only reason i didn't use gitpython here was the rest of the file didn't use it and i was minimising how much i changed

print("Set branch upstream tracking")
except subprocess.CalledProcessError as e:
print(f"Error setting branch upstream tracking: {e}")

try:
subprocess.check_call(f"cd /d {EPICS_PATH} && git pull", shell=True)
print("Pulled current branch from remote")
except subprocess.CalledProcessError as e:
print(f"Error pulling from remote: {e}")

try:
# run a git status to rebuild index if needed
subprocess.check_call(f"cd /d {EPICS_PATH} && git status", shell=True)
except subprocess.CalledProcessError as e:
print(f"Error running git status: {e}")

try:
subprocess.check_call(
f"cd /d {EPICS_PATH} && git checkout -b %COMPUTERNAME%", shell=True
Expand Down
Loading