Description
Describe the bug
When running moon ci :myTask
in a pull request in Azure DevOps, the build fails with the git diff command.
[DEBUG 23:25:22.271] moon_process::exec_command Running command git merge-base 419774e6f5c5383cfbc17d8e25697122eac63659 pid=4884 env={} cwd="C:\\a\\1\\s"
[DEBUG 23:25:22.298] moon_process::exec_command Running command git diff --name-status --no-color --relative --ignore-submodules -z refs/heads/main pid=2428 env={} cwd="C:\\a\\1\\s"
Error: process::failed
× Process git failed: exit code 128
│
│ fatal: ambiguous argument 'refs/heads/main': unknown revision or path not
│ in the working tree.
│ Use '--' to separate paths from revisions, like this:
│ 'git <command> [<revision>...] -- [<file>...]'
Steps to reproduce
- Create a pull request in Azure Devops for a merge to a branch with a build validation configured that runs a
moon ci
command. - The step for running moon fails
Expected behavior
It is expected that moon ci shall correctly work in Azure DevOps in this scenario.
Screenshots
None
Environment
None
Additional context
We have done some investigation and what we are observing is that Azure Devops checks out in a detached head state and there is no local main branch created, which is leading to the error.
We have found that if we use the --base option as follows, we can work around the issue.
--base $(System.PullRequest.targetBranchName)
This is not ideal though, as this will only work if the target branch is single word. Branches like foo/bar
would fail. Azure Devops provides the variable System.PullRequest.targetBranch
but this is prefixed with refs/heads/
, which the conan ci command does not handle.
Attached logs:
-
checkout.log
checkout.log: Azure pipeline logs of the checkout it does. -
moon.log: Azure pipeline log of the moon ci command.