Giter Club home page Giter Club logo

Comments (6)

f18m avatar f18m commented on July 22, 2024 2

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 " at some point and thus clones the git repo in a "HEAD detached" condition (https://www.git-tower.com/learn/git/faq/detached-head-when-checkout-commit/).
I tried and indeed a command like "git diff origin/develop..HEAD" in such condition fails with error

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 ?

from diff_cover.

dmcconnell-m avatar dmcconnell-m commented on July 22, 2024 1

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

from diff_cover.

Bachmann1234 avatar Bachmann1234 commented on July 22, 2024

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

from diff_cover.

Bachmann1234 avatar Bachmann1234 commented on July 22, 2024

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?

from diff_cover.

twall avatar twall commented on July 22, 2024

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).

from diff_cover.

altendky avatar altendky commented on July 22, 2024

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

Parquery/pylddwrap#20

from diff_cover.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.