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

Fix default branch extraction #250

Merged
merged 3 commits into from
Jul 27, 2022

Conversation

colinodell
Copy link
Collaborator

The regular expression used to extract default branch names failed to match dash and period characters. As a result, get_default_branch() would return incorrect results. For example:

Actual Branch Name Returned String
main main
2.x 2 <-- incorrect
my-default-branch my <-- incorrect
my_default_branch my_default_branch

This PR fixes this issue.

To test this, we also make a slight tweak to the _initialize_multiple_empty_repos() helper to set the default branch when the repository is first created. This requires using the -b / --initial-branch option added in git 2.28. The devbox Docker image was using an older version of git (2.20), so that has been updated to 2.30 via buster-backports, ensuring the tests pass both locally (via devbox) and via GitHub Actions.

@colinodell colinodell force-pushed the colinodell-fix-default-branch-extraction branch from cb0c390 to 0dad388 Compare July 27, 2022 19:08
@codecov
Copy link

codecov bot commented Jul 27, 2022

Codecov Report

Merging #250 (0dad388) into main (68fa58d) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main      #250   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines          164       164           
  Branches        22        22           
=========================================
  Hits           164       164           
Impacted Files Coverage Δ
pygitops/operations.py 100.00% <100.00%> (ø)

@colinodell colinodell merged commit 9664ad8 into main Jul 27, 2022
@colinodell colinodell deleted the colinodell-fix-default-branch-extraction branch July 27, 2022 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants