Skip to content

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

Merged

Conversation

JakeGinnivan
Copy link
Contributor

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.

|/
*
*
* (master)
Copy link
Contributor

@adamralph adamralph May 21, 2017

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   |
| _________/
|/
|
|
|

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice idea, have fixed

Copy link
Contributor Author

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)


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:
Copy link
Contributor

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.

Copy link
Member

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:

Copy link
Contributor Author

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

@@ -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.
Copy link
Contributor

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?

Copy link
Member

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.

- 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`.
Copy link
Contributor

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, what you cannot tell which branch was created first, release/1.0.0 or feature/foo.


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:
Copy link
Contributor

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 to about our branching workflows by telling it what types of branches it a branch can be created from. For example*,* feature branches are*,* by default*,* configured to have the following source branches:


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']`
Copy link
Contributor

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.

Copy link
Contributor Author

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


`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.
Copy link
Contributor

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 too in this way also improves the performance of GitVersion.


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
Copy link
Contributor

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)?

Copy link
Member

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?

### 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.
Copy link
Contributor

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.

Copy link
Member

@asbjornu asbjornu May 28, 2017

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. 🤔

Copy link

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.

@zvirja
Copy link

zvirja commented Jun 13, 2017

@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 😉

@JakeGinnivan
Copy link
Contributor Author

@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.
@JakeGinnivan JakeGinnivan force-pushed the feature/pick-better-merge-base branch from 6a075ec to de2d3f2 Compare June 18, 2017 02:59
@JakeGinnivan
Copy link
Contributor Author

Have addressed all the feedback, thanks all. Going to merge once builds are green.

@JakeGinnivan JakeGinnivan merged commit 00c26d4 into GitTools:master Jun 18, 2017
@JakeGinnivan JakeGinnivan deleted the feature/pick-better-merge-base branch June 18, 2017 05:46
@adamralph
Copy link
Contributor

@JakeGinnivan the final revision LGTM.

The only thing I still don't understand is how unstable can ever be the source branch for branches such as master, develop, hotfix, release or support as demonstrated in the is-source-branch-for example. I realise it's only an example, but is it demonstrating something that almost no-one would ever want to do? Or am I misunderstanding something?

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.

4 participants