rwjblue / git-repo-info

MIT License
112 stars 28 forks source link

No tag info visible #44

Open rturam opened 5 years ago

rturam commented 5 years ago

Hello,

For one repository the tag information is shown correctly on mac and windows but not on Amazon Linux. What can be the issue? How to debug?

I am running this code:

var getRepoInfo = require('git-repo-info');
var info = getRepoInfo();
console.log(info);

ON MAC:

{ sha: '3cbf8687a1290700841cd151b69ef4327c744d76',
  abbreviatedSha: '3cbf8687a1',
  branch: null,
  tag: '2.0.0',
  committer: null,
  committerDate: null,
  author: null,
  authorDate: null,
  commitMessage: null,
  root: '/Users/rt/projects/tmp/client-app',
  commonGitDir: '/Users/rt/projects/tmp/client-app/.git',
  worktreeGitDir: '/Users/rt/projects/tmp/client-app/.git',
  lastTag: '2.0.0',
  commitsSinceLastTag: 0 }

On Amazon linux (this is run jenkins slave machine - the code checkout and everything done in jenkisfile.)

{ sha: '3cbf8687a1290700841cd151b69ef4327c744d76',
  abbreviatedSha: '3cbf8687a1',
  branch: null,
  tag: null,
  committer: null,
  committerDate: null,
  author: null,
  authorDate: null,
  commitMessage: null,
  root: '/data/jenkins/workspace/FRONTEND-JOBS/deploy-job' }
rwjblue commented 5 years ago

What are the git --versions on each of the machines?

charlyoleg commented 5 years ago

I have the same issue on fresh cloned repos. If I commit anything in the same repo where I use git-repo-info, the issue disappear. With other words, on the same machine (Ubuntu 18.04), cloning the repo twice in two different directories, if I don't commit any thing in a repo-instance, I get the issue within this repo-instance.

rwjblue commented 5 years ago

Seems plausible that the clone doesn't include tags by default? Can you try git pull --tags on the machine that isn't showing them?

charlyoleg commented 5 years ago

After a fresh cloning and some git-pulls, I see the bug:

git clone https://github.com/charlyoleg/rouleau git pull git pull --tags

Then git-repo-info provides: { sha: '39af95c9d6db684a914601971a1a1c5a9da8824e', abbreviatedSha: '39af95c9d6', branch: 'master', tag: null, committer: null, committerDate: null, author: null, authorDate: null, commitMessage: null, root: '/home/charli/Bis/Tmp/test_bug_repo_info/client7/rouleau', commonGitDir: '/home/charli/Bis/Tmp/test_bug_repo_info/client7/rouleau/.git', worktreeGitDir: '/home/charli/Bis/Tmp/test_bug_repo_info/client7/rouleau/.git', lastTag: null, commitsSinceLastTag: Infinity }

More interesting, if the git-pull contains new commits, the bug is then gone: { sha: '822fa931f759b4f6523de6b576485b796c6d8a67', abbreviatedSha: '822fa931f7', branch: 'master', tag: null, committer: 'charli charlyoleg@fabfolk.com', committerDate: '2019-07-03T20:28:39.000Z', author: 'charli charlyoleg@fabfolk.com', authorDate: '2019-07-03T20:28:39.000Z', commitMessage: 'a dummy commit for bug investigation', root: '/home/charli/Bis/Tmp/test_bug_repo_info/client7/rouleau', commonGitDir: '/home/charli/Bis/Tmp/test_bug_repo_info/client7/rouleau/.git', worktreeGitDir: '/home/charli/Bis/Tmp/test_bug_repo_info/client7/rouleau/.git', lastTag: null, commitsSinceLastTag: Infinity, parents: [ '39af95c9d6db684a914601971a1a1c5a9da8824e' ] }

Might it be something related to the missing parents after a fresh clone?

charlyoleg commented 5 years ago

A short way to reproduce the issue: bash> git clone https://github.com/rwjblue/git-repo-info bash> cd git-repo-info bash> npm i bash> nodejs nodejs> const gitRepoInfo = require('./index'); nodejs> a=gitRepoInfo();

You will see: { sha: '416f9816d4883c74f91ac44c7bfbb956d569675a', abbreviatedSha: '416f9816d4', branch: 'master', tag: null, committer: null, committerDate: null, author: null, authorDate: null, commitMessage: null, root: '/home/charli/Bis/Tmp/ttt/git-repo-info', commonGitDir: '/home/charli/Bis/Tmp/ttt/git-repo-info/.git', worktreeGitDir: '/home/charli/Bis/Tmp/ttt/git-repo-info/.git', lastTag: null, commitsSinceLastTag: Infinity }

Using git version 2.17.1 nodejs v8.10.0

TomaszWegrzyn commented 4 years ago

Doesn't work for me either - lastTag is always null

I am using git-rev-sync-js as a replacement.

LightSeekerSC commented 7 months ago

Any new information on this? This was working for me and then suddenly only lastTag is null now