Skip to content

Stash branch & pull requests merges are not properly parsed when branch name contains a JIRA key #321

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
MacDennis76 opened this issue Dec 9, 2014 · 5 comments
Milestone

Comments

@MacDennis76
Copy link

We are using Stash in combination with JIRA. The branch names can contain a JIRA issue key, for example 'TOHISP-71'. Or: 'feature/TOHISP-71'.

Consider the following commit messages and pull requests and the logic in MergeMessageParser.cs:

"Merge pull request #2 in customer/project from feature/TOHISP-71 to master"
Will not result in a version.

"Merge pull request #4 in customer/project from TOHISP-52 to master"
Will result in a major version equal to '52'. Which is not correct.

Note that the repository is called 'customer/project' and contains a forward slash. The code in MergeMessageParser.cs counts the number of forward slashes when parsing a pull request merge and this fails when the repository name contains a forward slash and the branch name contains a JIRA issue key.

The logic which parses a merged branch also fails when the branch name contains a JIRA issue key.
Commit message example: "Merge branch 'feature/TOHISP-52' into release/1.4.0"
This results in a major version equal to '52'.
The logic splits the message by using a dash and takes the second hit. But the dash can be present X-times.

Repository names in Stash can contain a forward slash. And branch names can be equal to a single JIRA issue key which contains a dash and a number.

This issue is present in commit 2c902c3.

@MacDennis76 MacDennis76 changed the title Stash pull requests merges are not properly parsed when branch name is equal to JIRA key Stash branch & pull requests merges are not properly parsed when branch name contains a JIRA key Dec 9, 2014
@MacDennis76
Copy link
Author

Currently testing the following change in MergeMessageParser.cs:

        if (message.StartsWith("Merge branch '"))
        {
            var branch = message.Substring(message.IndexOf("'", System.StringComparison.Ordinal) + 1, message.Length - (message.IndexOf("'", System.StringComparison.Ordinal) + 1));
            branch = branch.Substring(0, branch.LastIndexOf("'", System.StringComparison.Ordinal));
            if (branch.Contains(".")) return branch.TryGetSuffix(out versionPart, "-");

            versionPart = null;
            return false;
        }

        if (message.StartsWith("Merge pull request #"))
        {
            if (message.Contains(" from "))
            {
                var branch = message.Substring(message.IndexOf(" from ", System.StringComparison.Ordinal) + 6, message.Length - (message.IndexOf(" from ", System.StringComparison.Ordinal) + 6));
                if (message.Contains(" to ")) branch = branch.Substring(0, branch.IndexOf(" to ", System.StringComparison.Ordinal));
                if (branch.Contains(".")) return branch.TryGetSuffix(out versionPart, "-");
            }

            versionPart = null;
            return false;
        }

@JakeGinnivan
Copy link
Contributor

What version are you using. The pull request merged about an hour ago into master fixes this issue (if you were using master)

@MacDennis76
Copy link
Author

Yes, I noticed. I was working the last couple of days with the source from commit 2c902c3, from the 5th of December from master.

Will check the latest version!

@MacDennis76
Copy link
Author

I can confirm that the latest version of master solves this issue.

@JakeGinnivan
Copy link
Contributor

Sweet, thanks for checking

@SimonCropp SimonCropp added this to the 2.1.0 milestone Jan 20, 2015
@SimonCropp SimonCropp added the bug label Jan 20, 2015
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

3 participants