Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using short commit hashes #123

Closed
josecelano opened this issue Apr 8, 2022 · 2 comments · Fixed by #142
Closed

Stop using short commit hashes #123

josecelano opened this issue Apr 8, 2022 · 2 comments · Fixed by #142
Labels
bug Something isn't working

Comments

@josecelano
Copy link
Member

We found a bug on a test project that was using git-queue.

When you create a commit git returns the short commit message (d3c882c):

$ git ci -m "add a.txt"
[main (root-commit) d3c882c] add a.txt
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 a.txt

We are using SimpleGit as a Git wrapper and it also returns the short commit hash probably because only returns what git commit command returns.

The bug was caused because git-queue assumes a fix short commit hash (7 chars).

As I discussed with @da2ce7 we should not rely on short hashes. Short hashes should be only used for the user interface because they are easier to handle by humans.

It seems neither the SimpleGit nor the git commit command itself has an option to return the full commit hash.

This is the object SimpleGit returns after committing:

{
  author: {
    email: '[email protected]',
    name: 'NautilusCyberneering[bot]'
  },
  branch: 'issue-22-job-commit-not-created',
  commit: 'df462c39',
  root: false,
  summary: { changes: 0, insertions: 0, deletions: 0 }
}

As you can see in that case the commit hash contains 8 chars. I asked them if there is an option to get the full hash. But we are pretty sure there is not because it seems git commit command does not have it either.

It seems the only way to get the full hash is with some "plumbing" git commands. I've already described here how to use git commit-tree to create the commit.

I guess we can use something similar in our SimplyGit wrapper.

@da2ce7
Copy link
Contributor

da2ce7 commented Apr 8, 2022

Please see comment: steveukx/git-js#782 (comment)

@josecelano
Copy link
Member Author

josecelano commented Apr 12, 2022

Please see comment: steveukx/git-js#782 (comment)

OK, then we only have to upgrade SimpleGit and remove ShortCommitHash class.

josecelano added a commit that referenced this issue Apr 13, 2022
Bug external project: nautilus-cyberneering/library-consumer#22
Issue: #123

The bug was temporarily fixes but setting git config with:

git config --global core.abbrev 7

We do not need it anymore becuase SimpleGit has force commit hash length
to the maximum (40 chararters). So we only use full hashes.
josecelano added a commit that referenced this issue Apr 13, 2022
Bug external project: nautilus-cyberneering/library-consumer#22
Internal issue: #123

The bug was temporarily fixed by setting git config to:

git config --global core.abbrev 7

We do not need it anymore becuase SimpleGit has force commit hash length
to the maximum (40 chararters). So we only use full hashes.
@josecelano josecelano linked a pull request Apr 13, 2022 that will close this issue
da2ce7 pushed a commit that referenced this issue Apr 13, 2022
Bug external project: nautilus-cyberneering/library-consumer#22
Internal issue: #123

The bug was temporarily fixed by setting git config to:

git config --global core.abbrev 7

We do not need it anymore becuase SimpleGit has force commit hash length
to the maximum (40 chararters). So we only use full hashes.
josecelano added a commit that referenced this issue Apr 18, 2022
Bug external project: nautilus-cyberneering/library-consumer#22
Internal issue: #123

The bug was temporarily fixed by setting git config to:

git config --global core.abbrev 7

We do not need it anymore becuase SimpleGit has force commit hash length
to the maximum (40 chararters). So we only use full hashes.
josecelano added a commit that referenced this issue Apr 18, 2022
Bug external project: nautilus-cyberneering/library-consumer#22
Internal issue: #123

The bug was temporarily fixed by setting git config to:

git config --global core.abbrev 7

We do not need it anymore becuase SimpleGit has force commit hash length
to the maximum (40 chararters). So we only use full hashes.
josecelano added a commit that referenced this issue Apr 18, 2022
Bug external project: nautilus-cyberneering/library-consumer#22
Internal issue: #123

The bug was temporarily fixed by setting git config to:

git config --global core.abbrev 7

We do not need it anymore becuase SimpleGit has force commit hash length
to the maximum (40 chararters). So we only use full hashes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants