Open twall opened 7 years ago
Howdy stranger!
I'll see if I can take a look at this. But as I've been saying in other things that have come up my free time has dried up dramatically recently so it may be a bit. We can talk in a less public forum if your curious.
But yeah, I'll try and look this week. No promises though
Hey, So the issue title makes me think you read the troubleshooting but I wanted to be extra sure.
When you say 'fetch master did not help' did you specifically make sure to try
git fetch origin master:refs/remotes/origin/master
from the readme?
No, I tried the troubleshooting tip, but it didn't work.
An explicit checkout of the target branch (master
) then switching back works, so I'm trying to figure out what happens differently in that case w/r/t symbolic references.
I believe if you do a fresh clone of a repo and snag a hash as described above you can reproduce reliably (don't need jenkins).
Hi @twall , @Bachmann1234 ,
I think I hit a similar problem. In my case I'm not using Jenkins but rather Teamcity. Also Teamcity does something like "git checkout -f
fatal: ambiguous argument 'origin/develop..HEAD': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]'
I'm not sure how to workaround this... any solution or workaround so far ?
For what it's worth... This didn't work.
- name: Make ${{ github.base_ref }} branch exist
run: |
git fetch origin master:refs/remotes/origin/master
diff_cover.command_runner.CommandError: fatal: ambiguous argument 'master...HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
But this did.
- name: Make ${{ github.base_ref }} branch exist
run: |
git checkout -b ${{ github.base_ref }} --track origin/${{ github.base_ref }}
git checkout -
Though now I'm just passing in the origin/master
or the parent hash depending. (isn't choosing either this or that just silly in GHA...)
- name: Run tox environment
env:
BASE_REF: ${{ fromJSON(format('[{0}, {1}]', toJSON(github.event.before), toJSON(format('origin/{0}', github.base_ref))))[github.base_ref != ''] }}
run: |
tox --skip-pkg-install -- --compare-branch="${BASE_REF}"
[testenv:check-coverage]
changedir = {toxinidir}
commands =
coverage combine coverage_reports/
coverage xml -o {toxinidir}/coverage.xml
coverage report --fail-under=90 --ignore-errors
diff-cover --fail-under=100 {posargs:--compare-branch=master} coverage.xml
I was able to get this to work in GitHub Actions by doing 2 separate checkouts in my workflow (1 for master / main first, then the branch / ref that triggered the workflow, my PR branch in my case):
- name: Check out the repo
uses: actions/checkout@v2
with:
ref: master
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.7"
- name: Install diff_cover
run: |
python -m pip install --upgrade pip
pip install diff_cover
- run: diff-cover coverage.xml --compare-branch=origin/master --diff-range-notation '..'
I have added this in case anyone else is trying to get diff_cover working with GitHub Actions
Jenkins SCM module does the following (minimal representation, it actually does a few more things):
If I invoke
git diff {branch}...HEAD
(as is done by diff-cover), I get the same error as is produced when running diff-cover:Preceding the diff with the recommended fetch does not work either:
In this case, TARGET_BRANCH is "master", which is the repo's default branch.
Output of "git branch":
The full Jenkins SCM operation looks like this: