git-repo-info
Advanced tools
Comparing version 1.3.0 to 1.3.1
30
index.js
@@ -23,12 +23,28 @@ 'use strict'; | ||
} else { | ||
// We have a file that tells us where to find the worktree git dir. Once we | ||
// look there we'll know how to find the common git dir, depending on | ||
// whether it's a linked worktree git dir, or a submodule dir | ||
var linkedGitDir = fs.readFileSync(gitPath).toString(); | ||
var worktreeGitDir = /gitdir: (.*)/.exec(linkedGitDir)[1]; | ||
var worktreeGitDirUnresolved = /gitdir: (.*)/.exec(linkedGitDir)[1]; | ||
var worktreeGitDir = path.resolve(worktreeGitDirUnresolved); | ||
var commonDirPath = path.join(worktreeGitDir, 'commondir'); | ||
var commonDirRelative = fs.readFileSync(commonDirPath).toString().replace(/\r?\n$/, ''); | ||
var commonDir = path.resolve(path.join(worktreeGitDir, commonDirRelative)); | ||
if (fs.existsSync(commonDirPath)) { | ||
// this directory contains a `commondir` file; we're within a linked | ||
// worktree | ||
return { | ||
worktreeGitDir: path.resolve(worktreeGitDir), | ||
commonGitDir: commonDir, | ||
}; | ||
var commonDirRelative = fs.readFileSync(commonDirPath).toString().replace(/\r?\n$/, ''); | ||
var commonDir = path.resolve(path.join(worktreeGitDir, commonDirRelative)); | ||
return { | ||
worktreeGitDir: worktreeGitDir, | ||
commonGitDir: commonDir, | ||
}; | ||
} else { | ||
// there is no `commondir` file; we're in a submodule | ||
return { | ||
worktreeGitDir: worktreeGitDir, | ||
commonGitDir: worktreeGitDir, | ||
}; | ||
} | ||
} | ||
@@ -35,0 +51,0 @@ } |
{ | ||
"name": "git-repo-info", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Retrieve current sha and branch name from a git repo.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9798
230