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

Bugfix/fix only tracked branches parameter implementation #1702

Conversation

crazycrank
Copy link
Contributor

Hey there

I'm currently playing around with GitVersion because we have some weird behaviors with our current branching strategy and what better way to learn something about git, branching and versioning then getting muddy in the code.

Anyway, it's late, my jokes get terrible and I found small bug.
In the class GitRepoMetadataProvider, the method GetBranchesContainingCommit has a parameter onlyTrackedBranches that parameter is actually implemented exactly the other way arround, so when set to true, all branches get scanned, with false only the tracked ones. I'll add a comment into the PR at the point.

I thought about renaming the parameter to allBranches or something like that, but that felt wrong naming wise, as it doesn't refer to tracking branches which this parameter is about. So I fixed up the implementation, and changed existing functionality to adapt the original behavior again. Three tests seem to be dependent on non-tracked branches which have been fixed up too.

If you have a better alternative name and prefer to just rename the parameter, just discard this PR. but it's not actually less work as the naming spreads through the hole call chain too :)

Have a good night.

@@ -77,7 +77,7 @@ public IEnumerable<Branch> GetBranchesContainingCommit(Commit commit, IList<Bran
// TODO: It looks wasteful looping through the branches twice. Can't these loops be merged somehow? @asbjornu
foreach (var branch in branches)
{
Copy link
Contributor Author

@crazycrank crazycrank Jun 5, 2019

Choose a reason for hiding this comment

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

This is the change I talked about in the PR. What the original dev probably meant was to use onlyTrackedBranches || !ibranch.IsTracking. I used the longer version (onlyTrackedBranches && branch.IsTracking) || !onlyTrackedBranches as its more verbose and thus makes sure this kind of bug doesn't happen :)

@crazycrank crazycrank marked this pull request as ready for review June 6, 2019 12:22
Copy link
Member

@asbjornu asbjornu left a comment

Choose a reason for hiding this comment

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

I think this looks good. However, the same boolean seems to be given three different names in the codebase:

  1. isForTrackedBranchOnly
  2. onlyTrackedBranches
  3. onlyEvaluateTrackedBranches

Is it possible to consolidate on one name for all of these? @arturcic, do these changes look sensible to you?

@arturcic
Copy link
Member

Looks good to me

@stale
Copy link

stale bot commented Sep 25, 2019

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 25, 2019
@asbjornu
Copy link
Member

@crazycrank, can you please look at my code review and rebase this PR to the HEAD of master?

@stale stale bot removed the stale label Oct 18, 2019
@asbjornu
Copy link
Member

asbjornu commented Jan 6, 2020

@crazycrank: Poke. 👉 😃

@crazycrank
Copy link
Contributor Author

Hey @asbjornu

I'm terribly sorry, this got burried in my inbox and I'm only rarely doing stuff on GitHub, so I have missed all your request. I'm trying to take a look at the PR on the weekends!

@asbjornu
Copy link
Member

asbjornu commented Jan 8, 2020

No problem, @crazycrank! Thanks for picking it up. 😃

@crazycrank crazycrank force-pushed the bugfix/fix-onlyTrackedBranches-parameter-implementation branch from 4813944 to 54baccd Compare January 19, 2020 13:18
@crazycrank
Copy link
Contributor Author

crazycrank commented Jan 19, 2020

Hey @asbjornu

I rebased my branch and aligned the naming throughout the solution (at least everything I could find). Take a look and write if you need any more changes!

I think there currently is one failing test (BranchVersionHavePrecedenceOverTagVersionIfVersionGreaterThanTag) when run in .NET Core 2.1, but it doesn't look as this is because of me

@asbjornu asbjornu merged commit c855918 into GitTools:master Jan 19, 2020
@asbjornu
Copy link
Member

Awesome, thanks for your contributions, @crazycrank! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants