Skip to content
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

Support Slash in Branch Names for Azure DevOps #835

Closed
shawnferry opened this issue Nov 12, 2019 · 7 comments
Closed

Support Slash in Branch Names for Azure DevOps #835

shawnferry opened this issue Nov 12, 2019 · 7 comments

Comments

@shawnferry
Copy link

Using Azure DevOps
atlantis 0.10.1

I've been able to create a otherwise identical branch called feature_newthing where Atlantis works as expected.

To reproduce create a pull request for a branch containing /s e.g. feature/NewThing the hook parsing seems to be getting .*/(.*)$ for the branch instead of something like refs/heads/(.*)

            "sourceRefName": "refs/heads/feature/NewThing",
            "targetRefName": "refs/heads/master",
2019/11/11 20:00:24-0500 [DBUG] working_dir.go:79 Repo/Name#5: Clone directory "/home/sferry/.atlantis/repos/Repo/Name/5/default" already exists, checking if it's at the right commit
2019/11/11 20:00:24-0500 [WARN] working_dir.go:94 Repo/Name#5: Will re-clone repo, could not determine if was at correct commit: git rev-parse HEAD: exit status 128: fatal: not a git repository (or any of the parent directories): .git

2019/11/11 20:00:24-0500 [INFO] working_dir.go:123 Repo/Name#5: Creating dir "/home/sferry/.atlantis/repos/Repo/Name/5/default"
2019/11/11 20:00:24-0500 [EROR] command_runner.go:410 Repo/Name#5: Running git clone --branch NewThing --depth=1 --single-branch https://<redacted>@dev.azure.com/Org/Repo/Name /home/sferry/.atlantis/repos/Repo/Name/5/default: Cloning into '/home/sferry/.atlantis/repos/Repo/Name/5/default'...
warning: Could not find remote branch NewThing to clone.
fatal: Remote branch NewThing not found in upstream origin
: exit status 128
@shawnferry
Copy link
Author

I'll try and dig into the code myself but I'm not sure I'll have time this week.

@lkysow
Copy link
Member

lkysow commented Nov 12, 2019

@mcdafydd maybe you can take a look?

@mcdafydd
Copy link
Contributor

Yes - I should have some time this week.

@shawnferry
Copy link
Author

@mcdafydd I tried to figure out where the branch is bring split from refs/head but trying a quick dive into this as a first foray into go hasn't worked out so far.

@mcdafydd
Copy link
Contributor

Thanks for jumping in @shawnferry. I have a little time tonight to dig in and will post an update as soon as I can.

@mcdafydd
Copy link
Contributor

It looks like this is coming from my usage of Path.Base() to get the branch name out of the webhook payload. Webhook payload looks like this:

"sourceRefName": "refs/heads/part1/part2",
"targetRefName": "refs/heads/master",

The issue is here:

HeadBranch: path.Base(headBranch),
HeadCommit: commit,
...
BaseBranch: path.Base(baseBranch),

So maybe we just change to split() and return everything after refs/heads. I'll try and get together a PR for this over the next day and add a test for it.

Great find!

@mcdafydd
Copy link
Contributor

I just ran a production test with this patch and it looks good.

mcdafydd added a commit to mcdafydd/atlantis that referenced this issue Nov 14, 2019
    - Improve tests
    - Replace instead of Split
@lkysow lkysow closed this as completed in 71239cf Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants