gitnexus 1.6.4-rc.66 → 1.6.4-rc.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/storage/git.js +18 -2
- package/package.json +1 -1
package/dist/storage/git.js
CHANGED
|
@@ -13,7 +13,17 @@ export const isGitRepo = (repoPath) => {
|
|
|
13
13
|
};
|
|
14
14
|
export const getCurrentCommit = (repoPath) => {
|
|
15
15
|
try {
|
|
16
|
-
return execSync('git rev-parse HEAD', {
|
|
16
|
+
return execSync('git rev-parse HEAD', {
|
|
17
|
+
cwd: repoPath,
|
|
18
|
+
// Suppress stderr -- without an explicit stdio option, Node's execSync
|
|
19
|
+
// forwards the child's stderr to the parent process (documented behaviour).
|
|
20
|
+
// When repoPath is not inside a git worktree, git prints
|
|
21
|
+
// "fatal: not a git repository" to stderr, which leaks to the user's
|
|
22
|
+
// terminal even though the error is caught here (#1172).
|
|
23
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
24
|
+
})
|
|
25
|
+
.toString()
|
|
26
|
+
.trim();
|
|
17
27
|
}
|
|
18
28
|
catch {
|
|
19
29
|
return '';
|
|
@@ -83,7 +93,13 @@ export const getRemoteUrl = (repoPath) => {
|
|
|
83
93
|
*/
|
|
84
94
|
export const getGitRoot = (fromPath) => {
|
|
85
95
|
try {
|
|
86
|
-
const raw = execSync('git rev-parse --show-toplevel', {
|
|
96
|
+
const raw = execSync('git rev-parse --show-toplevel', {
|
|
97
|
+
cwd: fromPath,
|
|
98
|
+
// Suppress stderr -- see getCurrentCommit comment and #1172.
|
|
99
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
100
|
+
})
|
|
101
|
+
.toString()
|
|
102
|
+
.trim();
|
|
87
103
|
// On Windows, git returns /d/Projects/Foo — path.resolve normalizes to D:\Projects\Foo
|
|
88
104
|
return path.resolve(raw);
|
|
89
105
|
}
|
package/package.json
CHANGED