-
Notifications
You must be signed in to change notification settings - Fork 651
Feature branch does not pick up version #1004
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
Feature branch does not pick up version #1004
Conversation
/cc @JakeGinnivan |
@maxraab Could you rebase this PR on the latest master, please? 😄 |
b85a3ed
to
7ce9d46
Compare
@asbjornu done 😄 |
I wonder if we should rename |
Sounds good, should I rename all occurences? |
Yeah, also you will need to add validation in the configuration provider to tell people it has renamed. |
7ce9d46
to
f42feae
Compare
@JakeGinnivan I've rebased to the current master and renamed |
f42feae
to
50f45ea
Compare
IsReleaseBranch = branchConfiguration.IsReleaseBranch; | ||
IsMainline = branchConfiguration.IsMainline; | ||
} | ||
|
||
[YamlMember(Alias = "mode")] | ||
public VersioningMode? VersioningMode { get; set; } | ||
public VersioningMode? VersioningMode |
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.
Can you please not reformat code that is not a part of your PR? 😃
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've restored the original format but we should improve that in another PR.
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.
@maxraab If the current ReSharper settings made the properties multiline, we should indeed fix that in its own PR.
f5ca9c3
to
895140b
Compare
895140b
to
6f327b9
Compare
@asbjornu @JakeGinnivan For some reason, the AppVeyor build fails.. How should I handle it? |
@maxraab It's the |
I've been thinking about this a bit, and I'm not so sure if this PR (while fixing the stated issue) actually makes sense. The way I understand GitVersion logically/conceptionally, i.e. not the actual implementation (to simplify, I'll ignore
The change with
This works. But the bug is that step 2 does not work properly:
The bug is that in step 2, the develop branch, when asked for its version number, acts as if Now the OP noticed that if the branch I think this solution tries to fix the bug at the wrong place. It essentially means that all branch configurations (except perhaps master) need to be marked that way. Also logically it makes no sense: Why do I need to mark a branch with I see two more sensible solutions:
Note that if my guess is correct, then there should be more bugs in the version calculation when version-calculation-relevant configs are different between two branches, such as |
@@ -18,7 +16,7 @@ public class BranchConfigurationCalculator | |||
if (matchingBranches.Length == 0) | |||
{ | |||
var branchConfig = new BranchConfig(); | |||
ConfigurationProvider.ApplyBranchDefaults(config, branchConfig); | |||
ConfigurationProvider.ApplyBranchDefaults(config, branchConfig, tracksReleaseBranches: true); |
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.
Not sure this is right actually as @DanielRose says. The default shouldn't be to track release branches because there could be feature branches off support branches or any number of other scenarios.
It is an odd one, because by branching from the develop branch it automatically bumps. |
@JakeGinnivan Looks good to me. It would be handy if all branches inherit settings of their parent branches (except the branch has specific settings). Anyway.. this bug prevents us using GitVersion. I hope we could fix it soon :) |
I created a number of tests, as #1009. When using "normally named" feature branches, ex. However, when using these "misnamed" feature branches, i.e. those without a config (as in this issue), it does not work. The reason seems to be the value of the increment strategy: The default value (in The documentation of increment is very short: The part of the SemVer to increment when GitVersion detects it needs to be (i.e commit after a tag). In the code, Inherit is additionally documented as Uses the increment strategy from the branch the current branch was branched from. But looking at the test results, and a quick look at the code in So what I previously described as step 2 is actually only done when the branch uses the Inherit strategy. So either the description or the code should be updated. Also, it would be useful to have a way for the user to set the default config values (i.e. those which are used when no branch config exists). Aside: In the tests, when an increment != Inherit is used, the calculated version number in the feature branch is different when a release branch is only created off develop/master, or the release branch is merged back. In the first case, no version number is found => uses 0.1.0 as base value. In the second case, the merged number (1.0) in the parent branch is then incremented according to the strategy of the feature branch (=> 2.0, 1.1, 1.0.1, ...), ignoring how it was incremented in the parent branch. |
@JakeGinnivan Can you comment on what should be done? |
I am not sure right now. Have DDD Perth tomorrow and this week has been pretty busy. Will try to catch up with this thread on Sunday |
@DanielRose is it just that the default should be inherit rather than patch? Or is there something else? |
@JakeGinnivan Well, the bug here would (more or less - the commit counts might be unexpected) be fixed if the default was inherit. However, this bug exposes that the behaviour of "increment" is different than what is documented (and expected - at least to me), as well as the behaviour when switching branches. Expected: Actual: An example (numbers don't make sense, just to illustrate):
|
In reality does this end up with a different version than us figuring out parent, calculating version then taking that version instead? I know the description doesn't exactly match what we end up doing, but if we switched the default over to inherit would that fix the incorrect versions. Or do we need to change the way we calculate the version when inheriting? |
I am happy for you to propose fixes, either to the docs or to the code so they line up. Also happy for default to change to inherit in v4. |
You can see the difference in the table I posted. On master, we are on version 2.0. Then branch to "child_minor", and suddenly the version is 1.1. Changing the default to inherit wouldn't help, since it has an explicit value "minor".
Ok, I'll try to find some time for that. |
@JakeGinnivan @DanielRose: What is the current state of play? |
@maxraab @JakeGinnivan I was on vacation. I'll take a closer look at the code in the next couple of days. |
I was able to take a closer look at the code and started looking how to fix this. Mainly so far I've added many comments to better understand what is being done. The main changes need to be done in the version calculators themselves. Those that work with the commits (ex. MergeMessageBaseVersionStrategy) use the LibGit Branch.Commits directly. However, a branch (and especially its commits) are defined by LibGit to include the parent branches as well. So I'll need to change this to have a property with the commits only of the current branch (i.e. only up to the point where the branch was created). So that is my next step, which I wasn't able to do so far. |
@DanielRose Are there any news concerning the version calculation? |
@maxraab I was able to get a list of branch configs and the commits belonging to them. Next I'll need to modify the version calculators to use that list instead. I'll try to find some time to continue working on it. |
@maxraab @JakeGinnivan I tried a bunch of approaches, but my idea fundamentally does not seem to work with Git. The problem is that Git has no concept of a "parent branch", since in its heart is a DAG with labels (see also http://stackoverflow.com/questions/3161204/find-the-parent-branch-of-a-git-branch). Lets say I have the following repository:
What branch does commit So when running GitVersion at commit BTW, the reason this was not a problem until now, is that looking for a "parent" branch only happened when the configuration said to inherit from the parent branch. That way we know there is a parent branch (or at least there is supposed to be one), and in the previous case it is clear that the commit So how can I salvage at least part of what I did? My suggestion would be:
|
Thanks for your patience @maxraab. I have rebased this. @DanielRose I don't think this and your branch are incompatible, I like the rename of is-develop to tracks-release-branch so want to get that part in. Going to pull your inherit changes in next |
based on a bug discovered in #988