Skip to content

"Merge tag '1.1.0' into support/1.0" is not recognized as merge commit #380

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

Closed
johannesegger opened this issue Mar 9, 2015 · 3 comments
Closed

Comments

@johannesegger
Copy link

When using git flow to merge a release branch back into a support branch it generates a commit message

Merge tag '1.1.0' into support/1.0

which is not recognized by gitversion as a valid commit message. When I ammend the commit to change "tag" to "branch" it works.

Why not use

git cat-file -p $gitsha

and count the number of parents to detect a merge commit. If there are more than one it is a merge commit. That would be more robust

C:\Users\egger\Workspace\GitVersionTest [support/1.0]> git cat-file -p 564cf5140fa30e85b07ba2f61dac70065eab93ca
tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
parent 7505a41a091f33e859c2311f5d76e7309a0240ff
parent fe420d45e9c69e68cf19014d7e1b5c112716091b
author Johannes Egger <[email protected]> 1425909409 +0100
committer Johannes Egger <[email protected]> 1425909409 +0100

Merge tag '1.1.0' into support/1.0
@JakeGinnivan
Copy link
Contributor

I see you have submitted a PR already, but a more flexible option I see would be to do something like this though:

config.Repository
  .Commits
  .Where(c => c.Parents.Count > 1)
  .Select(c => c.Message.Split('/', '-', '\'', '"', ' '))
  .SelectMany(parts => {
    foreach (var part in parts) {
      SemanticVersion version;
      if (SemanticVersion.TryParse(part, out version)) {
        yield return version;
      }
    }
  });

Which basically will find all merge commits (maybe a commit query to find all commits with multiple parents would be more efficient, @nulltoken ?) then split the commit message up and try and find a version number in the merge commit. If it finds one it can return it. Thoughts on doing something like this instead of just chaining more if's?

@johannesegger
Copy link
Author

I'll have a look at the 3.0 branch and get you some feedback

@johannesegger
Copy link
Author

Turned out easy.

        static bool Inner(Commit mergeCommit, out string versionPart)
        {
            if (mergeCommit.Parents.Count() < 2)
            {
                versionPart = null;
                return false;
            }

            var version = mergeCommit
                .Message.Split('/', '-', '\'', '"', ' ')
                .Select(part =>
                {
                    SemanticVersion v;
                    return SemanticVersion.TryParse(part, "", out v) ? v : null;
                }).FirstOrDefault(v => v != null)
                ;

            versionPart = version!=null ? version.ToString() : null;

            return versionPart != null;
        }

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

No branches or pull requests

2 participants