-
Notifications
You must be signed in to change notification settings - Fork 77
add git information to config file #947
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
Open
Ian0sborne
wants to merge
6
commits into
next-exp:master
Choose a base branch
from
Ian0sborne:add-IC-tag
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gonzaponte
reviewed
Nov 4, 2025
gonzaponte
reviewed
Nov 5, 2025
Contributor
Author
|
I still haven't finished all the comments, but what do you think of the testing function so far? I wanted to hear your opinion before I committed it. def test_add_git_info():
try:
# keep a copy of the current branch
current_branch = run_git_command("git branch --show-current")
# create a testing branch
testing_branch = 'function-testing-branch'
run_git_command(f"git checkout -b {testing_branch}")
# create an empty testing commit
run_git_command("git commit --allow-empty -m 'create_dummy_commit'")
testing_commit_hash = run_git_command("git log --pretty=format:%H -n 1") # alternative way of extracting hash
# create a testing remote upstream
testing_upstream = 'function-testing-upstream'
run_git_command(f"git remote add {testing_upstream} .") # use current repo as remote
run_git_command(f"git branch --set-upstream-to {testing_upstream}/{testing_branch}")
run_git_command(f"git push -u {testing_upstream} {testing_branch}") # add this otherwise remote = None
# create a temporary tag for testing
testing_tag = 'v.function.testing.tag'
run_git_command(f"git tag {testing_tag}")
extracted_git_info = add_git_info()
assert extracted_git_info['branch_name'] == testing_branch
assert extracted_git_info['commit_hash'] == testing_commit_hash
assert extracted_git_info['upstream_name'] == testing_upstream
assert extracted_git_info['IC_tag'] == testing_tag
except Exception as e:
print(f"Something went wrong: {e}")
raise
finally:
# cleanup happens no matter what, each command is within a try/except so that if one fails the rest still run
# switches back to the original branch
try:
run_git_command(f"git checkout {current_branch}")
except Exception as e:
print(f"Failed to restore branch {current_branch}: {e}")
try:
run_git_command(f"git tag -d {testing_tag}")
except Exception as e:
print(f"Failed to delete tag {testing_tag}: {e}")
# delete local testing branch
try:
run_git_command(f"git branch -D {testing_branch}")
except Exception as e:
print(f"Failed to delete branch {testing_branch}: {e}")
# delete remote testing branch
try:
run_git_command(f"git push {testing_upstream} --delete {testing_branch}")
except Exception as e:
print(f"Failed to delete remote branch {testing_branch} on {testing_upstream}: {e}")
try:
run_git_command(f"git remote remove {testing_upstream}")
except Exception as e:
print(f"Failed to remove remote {testing_upstream}: {e}") |
Collaborator
|
Please remind me where we left things here. Is this ready for another review? |
Contributor
Author
|
Hey Gonzalo! We still have to commit the new testing function and clean up some of the weird commits we made when testing stuff together. I will get back on it on Monday. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses #945 by including Git information into city config files. A function
add_git_info(conf)is introduced, which adds information about the IC tag, upstream remote name, branch name and commit hash to the city config file.