-
Notifications
You must be signed in to change notification settings - Fork 653
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
[IMPROVEMENT]: Topological commit sort causes issues when master is merged into a feature branch #4347
Comments
Please provide steps to reproduce (not only a graphic) by creating:
Thank you very much. |
@HHobeck Thanks for your response. Checkout branch "feature". I used the following command to calculate the version: |
Okay thanks for creating the repository. If I see your configuration file I think it is not really necessary to overwhelm the contributors with irrelevant information. I would like to have a minimal example based on the given supported workflows like workflow: GitFlow/v1
tag-prefix: '(?i)PRODUCTNAME[:\s_\/vV]*'
minor-version-bump-message: '\+(sem)?ver\s?PRODUCTNAME[:\s_\/]*(feature|minor)' |
I see your use case and think it might be a good idea for improvement. I think the code which needs to be changed is located in the following class:
I'm not sure if it will break other scenarios. Thus I would recommend you to create a prototype first and see if integration tests are failing. If we know this we can make a decision whether or not a new configuration property needs to be introduced. |
@HHobeck I have implemented a prototype which works for the described scenario. Only two tests are still failing, one of which is a performance test, and the other one interacts with a more complex configuration, which maybe a repository maintainer could take a look at? Let me know if you want a Pull Request, integration test, etc., but I would greatly appreciate a repository maintainer completing this :) |
@dauthleikr: Great work. Thank you very much. I think you can use the following function to determine the graph history: var intermediateCommits = this.repositoryStore.GetCommitLog(
baseVersionSource: baseVersionSource,
currentCommit: currentCommit,
ignore: ignore
); |
Integration test: [TestCase(false, "2.0.0-alpha.3")]
[TestCase(true, "3.0.0-alpha.2")]
public void EnsureVersionAfterMainIsMergedBackToDevelopIsCorrectForGitFlow(bool applyTag, string semanticVersion)
{
var configuration = GitFlowConfigurationBuilder.New.Build();
using var fixture = new EmptyRepositoryFixture();
fixture.MakeACommit("A");
fixture.ApplyTag("1.0.0");
fixture.BranchTo("develop");
fixture.MakeACommit("B +semver: major");
// ✅ succeeds as expected
fixture.AssertFullSemver("2.0.0-alpha.1", configuration);
fixture.Checkout("main");
fixture.MakeACommit("C");
if (applyTag) fixture.ApplyTag("2.0.0");
fixture.Checkout("develop");
fixture.MergeNoFF("main");
// ✅ succeeds as expected
fixture.AssertFullSemver(semanticVersion, configuration);
} Performance test: @asbjornu: What do you think? The time increased from under 5 seconds to 18 seconds for a repository with 500 tags. |
I think we should avoid decreasing the performance of GitVersion, as we already have complaints about it being too slow in many scenarios. In this particular scenario, why is |
Of course we need to address the performance issue. That's why we are talking about. From the business perspective it feels not right that the commit In my opinion we cannot force the user to always do a rebase. If you think about the risk when rewriting the history of the develop branch. This is normally a no-go and not recommended. I see the scenario of the author realistic. Three actions coming to my mind to mediate the performance problem:
|
Yes, sadly we cannot enforce a rebase-only workflow. I briefly had time to profile this from my work machine - I found that most of the performance cost comes from repeated repository accesses, all the implemented commit caches always miss. I refactored one of the methods to not only cache its own result, but also cache all the children that come with it. I was able to achieve a 10x performance gain on the performance integration test with this experiment. Unfortunately I have to head out and do not have the time to run the tests, I believe they will take another half hour to run on this machine. I might get back to it tomorrow. Feel free to experiment with the following changed method from private ICommit[] GetHeadCommits(ICommit? headCommit, IIgnoreConfiguration ignore)
{
var key = headCommit?.Sha ?? "NULL";
if (!this.headCommitsCache.TryGetValue(key, out var commits))
{
commits = [.. this.repositoryStore.GetCommitsReacheableFromHead(headCommit, ignore)];
this.headCommitsCache[key] = commits;
for (var i = commits.Length - 2; i >= 0; i--)
{
var prevKey = commits[i]?.Sha ?? "NULL";
this.headCommitsCache.TryAdd(prevKey, commits[..(i + 1)]);
}
}
return commits;
} |
Prerequisites
GitVersion package
GitVersion.Tool
GitVersion version
6.0.2+Branch.main.Sha.30211316bc16e481dc440baae39ff904c4fa4966
Operating system
Windows
What are you seeing?
Consider the following commit graph, where green is a feature branch, and pink is master.
Configuration:
The idea of this configuration is as follows:
Even though the feature branch contains a bump message, it is not respected, because a merge from master into the feature branch happened, after the bump message was created. Without the merge, everything is fine.
We want merges from master into feature branches to be possible, without the bump message getting lost.
Example:
What is expected?
Somehow consider the bump messages from before the merge of master into my feature branch. The bump version commit is not discoverable from the head of master, but it is discoverable from the head of my feature branch, so I feel like it should be possible to implement.
The issue can also be "fixed" by changing the filter in
GetCommitsReacheableFromHead
toCommitSortStrategies.Topological | CommitSortStrategies.Time | CommitSortStrategies.Reverse
, orCommitSortStrategies.Time | CommitSortStrategies.Reverse
(which seems to be the default forgit log
), but is not optimal for obvious reasons.Steps to Reproduce
Please recreate the commit graph shown above. Sorry for the heavy redaction :(
RepositoryFixture Test
No response
Output log or link to your CI build (if appropriate).
The text was updated successfully, but these errors were encountered: