-
Notifications
You must be signed in to change notification settings - Fork 654
Pick better merge base #1225
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
Pick better merge base #1225
Conversation
f7f14e7
to
6f3e788
Compare
docs/configuration.md
Outdated
|/ | ||
* | ||
* | ||
* (master) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not obvious to me what each branch label refers to in this diagram. I think the branch labels should really be shown next to the head commit of the branch.
Specifically, I'm not sure if you mean this:
* feature/foo
* master | release/1.0.0 // head of release branch behind head of feature branch
| _________/
|/
|
|
or this:
* feature/foo, release/1.0.0 // head of both branches is the same
* master |
| _________/
|/
|
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice idea, have fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was
* release/1.0.0 * feature/foo
| ________________/
|/
*
*
* (master)
docs/configuration.md
Outdated
|
||
Or put more simply, what branch was created first, `release/1.0.0` or `feature/foo`. | ||
|
||
To resolve this issue we give GitVersion a hint to how we normally do our branching, feature branches have a value of: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps the fault is on me, but this sentence, and the following list, do not make any sense to me. I've honestly no idea what you mean by "feature branches have a value of", and what information the list is designed to convey.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what's meant is what the default configuration for feature branches is. So doing GitVersion init
should give you a GitVersion.yml
containing the list below. Perhaps a better description would be:
To resolve this issue, we give GitVersion a hint to how we normally do our branching. Feature branches are by default configured to have the following source branches:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewrote it, hopefully makes it a bit clearer
docs/configuration.md
Outdated
@@ -243,6 +243,47 @@ values, but here they are if you need to: | |||
### regex | |||
This is the regex which is used to match the current branch to the correct branch configuration. | |||
|
|||
### source-branches | |||
Because git is a directed graph GitVersion sometimes cannot tell which branch the current branch was branched from. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because git is a directed graph...
I'm guessing that a significant number of people won't know what this means, and it seems redundant. Perhaps remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's valuable to point out that sometimes GitVersion can't figure out the origin of the current branch. Whether that's because it's a DAG or not is perhaps not that important.
docs/configuration.md
Outdated
- Add a commit to both release/1.0.0 and feature/foo | ||
- feature/foo is the base for release/1.0.0 | ||
|
||
Or put more simply, what branch was created first, `release/1.0.0` or `feature/foo`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest:
Or put more simply,
whatyou cannot tell which branch was created first,release/1.0.0
orfeature/foo
.
docs/configuration.md
Outdated
|
||
Or put more simply, what branch was created first, `release/1.0.0` or `feature/foo`. | ||
|
||
To resolve this issue, we give GitVersion a hint to our branching workflows by telling it what types of branches it can be created from. For example feature branches are by default configured to have the following source branches: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest:
To resolve this issue, we give GitVersion a hint
toabout our branching workflows by telling it what types of branchesita branch can be created from. For example*,* feature branches are*,* by default*,* configured to have the following source branches:
docs/configuration.md
Outdated
|
||
To resolve this issue, we give GitVersion a hint to our branching workflows by telling it what types of branches it can be created from. For example feature branches are by default configured to have the following source branches: | ||
|
||
`sourceBranches: ['master', 'develop', 'feature', 'hotfix', 'support']` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this list correct? Under GitFlow I was under the impression that feature branches should only be created from, and merged to, develop
. And for GitHubFlow, master
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This configuration param is for all flows, GitVersion actually doesn't know about the different workflows, it just has branch configuration which works for both
docs/configuration.md
Outdated
|
||
`sourceBranches: ['master', 'develop', 'feature', 'hotfix', 'support']` | ||
|
||
This means that we will never bother to evaluate pull request branches as merge base options, being explicit like this helps GitVersion be much faster too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest:
This means that we will never bother to evaluate pull request branches as merge base options~,~ and being explicit
like this helps GitVersion be much faster tooin this way also improves the performance of GitVersion.
docs/configuration.md
Outdated
|
||
This means that we will never bother to evaluate pull request branches as merge base options, being explicit like this helps GitVersion be much faster too. | ||
|
||
### is-source-branch-for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this kebab-cased, whereas sourceBranches is camelCased above (but kebab-cased below)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kebab case would be more consistent, so I believe the camel casing is a typo?
docs/configuration.md
Outdated
### is-source-branch-for | ||
The reverse of the above setting. This property was introduced to keep it easy to extend GitVersion's config. | ||
|
||
When you add a new branch type this allows you to specify both source-branches for the new branch, and also add the new branch to existing branch configurations. For example if you create a new branch called `unstable` you could set a value of `['release', 'master', 'feature']` etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, it might be me, but I don't get this at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamralph: It's not just you. I don't get how the branch unstable
can be the source branch for release
, master
or feature
. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more point is to not use position depending things like "above setting". It's always better to refer to the setting by name, so that later description will not be broken due to changed sorting.
@JakeGinnivan Do you currently have any time to follow up? 😳 I have yet another thing that I need improve in this direction, so I would like to base my PR on your one. Given that the documentation stuff is under the discussion only, it looks not too much left 😉 |
@zvirja sorry, will get the feedback addressed and just merge |
This allows GitVersion to know what branches it should take into account for calculating merge base. This locks it down a little more, but is an easier to explain behavior than commit counting randomly resetting because GitVersion cannot effectively figure out which branch the current branch was branched off.
6a075ec
to
de2d3f2
Compare
Have addressed all the feedback, thanks all. Going to merge once builds are green. |
@JakeGinnivan the final revision LGTM. The only thing I still don't understand is how |
Builds on #1224, includes the test from #1204 and gets it passing.
This change allows GitVersion to better decide which branch the current branch was likely branched from. Have added some new configuration options and updated the related docs.
Would love any other ideas on how to solve this problem better.