pronto: Rugged 1.7.1 breaks gem

Rugged update 1.7.1 which came out yesterday breaks the gem.

I’m using it in a github action.

/lib/rugged/repository.rb:114:in `diff': undefined method `[]' for nil:NilClass (NoMethodError)

        right.diff(left, opts.merge(:reverse => !opts[:reverse]))
                                                     ^^^^^^^^^^
	from /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/pronto-0.11.1/lib/pronto/git/repository.rb:30:in `diff'
	from /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/pronto-0.11.1/lib/pronto.rb:64:in `run'
	from /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/pronto-0.11.1/lib/pronto/cli.rb:70:in `block in run'
	from /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/pronto-0.11.1/lib/pronto/cli.rb:6[8]:in `chdir'
	from /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/pronto-0.11.1/lib/pronto/cli.rb:68:in `run'
	from /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor/command.rb:27:in `run'
	from /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in `invoke_command'
	from /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor.rb:3[9]2:in `dispatch'
	from /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor/base.rb:485:in `start'
	from /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/pronto-0.[11].1/bin/pronto:6:in `<top (required)>'
	from /opt/hostedtoolcache/Ruby/3.1.4/x64/bin/pronto:25:in `load'
	from /opt/hostedtoolcache/Ruby/3.1.4/x64/bin/pronto:25:in `<main>'

Github action workflow:

---
name: Pronto
on: [pull_request]

jobs:
  pronto:
    if: ${{ !contains(github.actor, '[bot]') }}
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - run: |
          git fetch --no-tags --prune --depth=50 origin +refs/heads/*:refs/remotes/origin/*
      - name: Setup Ruby
        uses: ruby/setup-ruby@v1
      - name: Setup pronto
        run: gem install rubocop-rails pronto pronto-rubocop
      - name: Run Pronto
        run: >
          PRONTO_PULL_REQUEST_ID="${{ github.event.pull_request.number }}"
          PRONTO_GITHUB_ACCESS_TOKEN="${{ github.token }}"
          pronto run -f github_status text -c origin/${{ github.base_ref }}

Fixed by pinning rugged to 1.6.3. Action runs with ruby 3.1.4 which is specified in our .ruby-version.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 9
  • Comments: 21 (10 by maintainers)

Commits related to this issue

Most upvoted comments

If you’re here because you’re seeing a Github Action failing with this error, you can pin your version of rugged to 1.6.3 by updating the Github Actions Integration example code as follows:

...
      - name: Setup pronto
        run: gem install rugged:1.6.3 pronto pronto-rubocop
...

@jeantristan see this comment from the PR author @X-sam – it seems to be a bug in rugged itself.

This is happening because Pronto.run is being called without a file which then causes the options being passed to repo.diff to be nil. The nil options are then passed to @repo.diff(merge_base, head, options)

Simple fix is to do this:

patches = @repo.diff(merge_base, head, options || {})

https://github.com/prontolabs/pronto/blob/v0.11.2/lib/pronto/cli.rb#L70 https://github.com/prontolabs/pronto/blob/v0.11.2/lib/pronto.rb#L59 https://github.com/prontolabs/pronto/blob/v0.11.2/lib/pronto.rb#L64 https://github.com/prontolabs/pronto/blob/v0.11.2/lib/pronto/git/repository.rb#L30 https://github.com/libgit2/rugged/blob/v1.7.1/lib/rugged/repository.rb#L114

Is there any reason not to make this one line change? As someone who’s impacted by this, it would be nice to be able to use Pronto alongside a less deep checkout.

@cooljacob204 can you try removing that git fetch ... after the actions/checkout step. Also try adding fetch depth of 0 on the checkout.

      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

No error with this version of the checkout step.