# Git clone cannot merge when PR build is triggered from api

**URL:** <https://discuss.bitrise.io/t/git-clone-cannot-merge-when-pr-build-is-triggered-from-api/7292>\
**Category:** Tooling Issues\
**Created:** [December 9, 2018, 12:46am UTC](https://discuss.bitrise.io/t/git-clone-cannot-merge-when-pr-build-is-triggered-from-api/7292 "2018-12-09T00:46:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![aladdinG](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@aladdinG](https://discuss.bitrise.io/u/aladdinG)\
**Post date:** [December 9, 2018, 12:46am UTC](https://discuss.bitrise.io/t/git-clone-cannot-merge-when-pr-build-is-triggered-from-api/7292/1 "2018-12-09T00:46:20Z")

</div>

Hi,

Im trying to great a PR from VSTS (since they are no yet supported : [Pull Request support for AzureDevOps (VSTS)](http://discuss.bitrise.io/t/pull-request-support-for-azuredevops-vsts/6992))  
A PR build will be triggered in Bitirse using the api when needed. the api request will look like this :

```
{
  "hook_info": {
    "type": "bitrise",
    "build_trigger_token": "..."
  },
  "build_params": {
    "branch": "feature/testPr",
    "workflow_id": "ci",
    "branch_dest": "develop",
    "pull_request_id": 12345,
  }

```

}

That 'c’i workflow works without any problem with a simple trigger (in the dashboard or even in the api when branch\_dest & pull\_request\_id are not passed ).  
But following that request this is the result : it’s obviously a merge issue, but that feature/testPr branch have minimal change and it merge gracefully with develop without any problem in my machine.

```
git "init"
Initialized empty Git repository in /Users/vagrant/git/.git/
git "remote" "add" "origin" "myorganization@vs-ssh.visualstudio.com:v3/myorganization/myproject/myrepo"
git "fetch" "origin" "develop"
Warning: Permanently added 'vs-ssh.visualstudio.com,XX.XX.XX.XX' (RSA) to the list of known hosts.
From vs-ssh.visualstudio.com:v3/myorganization/myproject/myrepo
 * branch develop -> FETCH_HEAD
 * [new branch] develop -> origin/develop
git "checkout" "develop"
Switched to a new branch 'develop'
Branch 'develop' set up to track remote branch 'develop' from 'origin'.
Already up to date.
commit hash: 123c....8
git "fetch" "origin" "feature/testPr"
Warning: Permanently added 'vs-ssh.visualstudio.com,XX.XX.XX.XX' (RSA) to the list of known hosts.
From vs-ssh.visualstudio.com:v3//myorganization/myproject/myrepo
 * branch feature/testPr -> FETCH_HEAD
 * [new branch] feature/testPr -> origin/feature/testPr
git "merge" ""
merge: - not something we can merge
ERROR: manual merge, error: merge failed (), error: exit status 1

```

I tried to alternate `Manual merge` setting between yes and no but ti fails anyway : (the following is when is set to yes)

```
git "init"
Initialized empty Git repository in /Users/vagrant/git/.git/
git "remote" "add" "origin" "myorganization@vs-ssh.visualstudio.com:v3/myorganization/myproject/myrepo"
git "fetch" "origin" "develop"
Warning: Permanently added 'vs-ssh.visualstudio.com,XX.XX.XX.XX' (RSA) to the list of known hosts.
commit hash: 123c....8
git "fetch" "origin" "feature/testPr"
Warning: Permanently added 'vs-ssh.visualstudio.com,65.52.8.37' (RSA) to the list of known hosts.
From vs-ssh.visualstudio.com:v3//myorganization/myproject/myrepo
 * branch feature/testPr -> FETCH_HEAD
 * [new branch] feature/testPr -> origin/feature/testPr
git "merge" ""
merge: - not something we can merge
ERROR: manual merge, error: merge failed (), error: exit status 1

```

Any idea how I can make this work ?

---

<div class="post-metadata">

**Author:** ![bitce](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/bitce/32/1639_2.png) [@bitce](https://discuss.bitrise.io/u/bitce)\
**Post date:** [December 10, 2018, 4:01pm UTC](https://discuss.bitrise.io/t/git-clone-cannot-merge-when-pr-build-is-triggered-from-api/7292/2 "2018-12-10T16:01:03Z")

</div>

Hi @aladdinG!

Can you please include a build URL we could take a look at as well?

---

<div class="post-metadata">

**Author:** ![aladdinG](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@aladdinG](https://discuss.bitrise.io/u/aladdinG)\
**Post date:** [December 11, 2018, 9:28am UTC](https://discuss.bitrise.io/t/git-clone-cannot-merge-when-pr-build-is-triggered-from-api/7292/3 "2018-12-11T09:28:30Z")

</div>

@bitce here you go ttps://app.bitrise.io/build/f6d3e89e584d58b8

---

<div class="post-metadata">

**Author:** ![fehersanyi-bitrise](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/fehersanyi-bitrise/32/1912_2.png) [@fehersanyi-bitrise](https://discuss.bitrise.io/u/fehersanyi-bitrise)\
**Post date:** [December 11, 2018, 2:16pm UTC](https://discuss.bitrise.io/t/git-clone-cannot-merge-when-pr-build-is-triggered-from-api/7292/4 "2018-12-11T14:16:24Z")

</div>

Hello @aladdinG!

Could you try with clone depth set to 1?

---

<div class="post-metadata">

**Author:** ![aladdinG](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@aladdinG](https://discuss.bitrise.io/u/aladdinG)\
**Post date:** [December 11, 2018, 10:01pm UTC](https://discuss.bitrise.io/t/git-clone-cannot-merge-when-pr-build-is-triggered-from-api/7292/5 "2018-12-11T22:01:41Z")

</div>

> [@fehersanyi-bitrise](#):
>
> Hello @aladdinG!
> 
> Could you try with clone depth set to 1?

Is not working.

With Auto Merge Yes : [Bitrise - Mobile Continuous Integration and Delivery - iOS & Android Build Automation](https://app.bitrise.io/build/0df310ce8745c7c8)  
With Auto Merge No : [Bitrise - Mobile Continuous Integration and Delivery - iOS & Android Build Automation](https://app.bitrise.io/build/0d2cec7119e77270)

---

<div class="post-metadata">

**Author:** ![aladdinG](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@aladdinG](https://discuss.bitrise.io/u/aladdinG)\
**Post date:** [December 15, 2018, 10:03pm UTC](https://discuss.bitrise.io/t/git-clone-cannot-merge-when-pr-build-is-triggered-from-api/7292/6 "2018-12-15T22:03:25Z")

</div>

Any status for this issue?

---

<div class="post-metadata">

**Author:** ![laszlo.szucs](https://avatars.discourse-cdn.com/v4/letter/l/df705f/32.png) [@laszlo.szucs](https://discuss.bitrise.io/u/laszlo.szucs)\
**Post date:** [December 18, 2018, 4:28pm UTC](https://discuss.bitrise.io/t/git-clone-cannot-merge-when-pr-build-is-triggered-from-api/7292/7 "2018-12-18T16:28:03Z")

</div>

Hi @aladdinG,

```auto
git "merge" ""
merge: - not something we can merge

```

The error messages above shows that the merge command does not receive a valid branch name: it gets an empty string.

It isn’t trivial, but this branch argument comes from a `commit` environment variable, which ultimately comes from a `commit_hash` parameter in the request body. The underlying layers use the Bitrise Trigger API. I linked the relevant lines in the source code and some docs below.

Let me know if this helps! 🙂

Links:

- [https://github.com/bitrise-io/steps-git-clone/blob/a8ba7ff8b83787d4b94b51b6d99ef0673984aa98/main.go#L96](https://github.com/bitrise-io/steps-git-clone/blob/a8ba7ff8b83787d4b94b51b6d99ef0673984aa98/main.go#L96)

- [https://github.com/bitrise-io/steps-git-clone/blob/a8ba7ff8b83787d4b94b51b6d99ef0673984aa98/git.go#L252](https://github.com/bitrise-io/steps-git-clone/blob/a8ba7ff8b83787d4b94b51b6d99ef0673984aa98/git.go#L252)

- [https://devcenter.bitrise.io/api/build-trigger/#pull-request-specific](https://devcenter.bitrise.io/api/build-trigger/#pull-request-specific)

---

<div class="post-metadata">

**Author:** ![aladdinG](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@aladdinG](https://discuss.bitrise.io/u/aladdinG)\
**Post date:** [December 18, 2018, 11:15pm UTC](https://discuss.bitrise.io/t/git-clone-cannot-merge-when-pr-build-is-triggered-from-api/7292/8 "2018-12-18T23:15:20Z")

</div>

thank you @laszlo.szucs. Actually it did help. I had to specify the commit\_hash instead to make it work.  
I’ts look like if this context the branch is ignored or something when it’s a PR merge it just ignore the branch and only take the commit\_hash ?  
If it’s the case the documentation in [https://devcenter.bitrise.io/api/build-trigger/#pull-request-specific](https://devcenter.bitrise.io/api/build-trigger/#pull-request-specific) need to be updated/fixed … Or maybe I missed something ?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/bitrise/original/2X/d/d901cf2aad020f2dd11918afc89ec2089bb87b35.png) [@system](https://discuss.bitrise.io/u/system)\
**Post date:** [January 17, 2019, 11:15pm UTC](https://discuss.bitrise.io/t/git-clone-cannot-merge-when-pr-build-is-triggered-from-api/7292/9 "2019-01-17T23:15:29Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
