gitgerrit

How can I get the change id for the latest Gerrit commit


I am automating a simple Gerrit workflow of commit, push and approve a change. Sometimes the pushes fail with an error message

[Nest] 91608  - 02/02/2024, 8:27:46 PM   ERROR 
Error: To ssh://git.xxxx:1234/somerepo.git
!       refs/heads/CICCORNERSTONE:refs/for/CICCORNERSTONE       [remote rejected] (no new changes)
Done
Pushing to ssh://git.xxxx:1234/somerepo.git
remote: Processing changes: refs: 1, done
error: failed to push some refs to 'ssh://git.xxxx:1234/somerepo.git'

The situation where I see these errors is when a commit is pushed, a CR is created and abandoned. Unfortunately for some reason beyond my control the change is pushed again, and that is when the above error is thrown.

As per the documentation mentioned at https://gerrit-review.googlesource.com/Documentation/error-no-new-changes.html

we can find the change associated with the commit id.

Could you advise me on

  1. How do we find the latest commit id since the above error does not show that.
  2. Is there an automated way (e.g. via APIs) that we can find the change number for the given commit id

Thanks, Prabal


Solution

  • Just use:

    git commit --amend
    

    Then while editing the description, delete the "Change-Id:" line. When you save it, a new one is generated. Then Gerrit will accept your change.