gitnexus 1.6.8-rc.33 → 1.6.8-rc.34
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 +5 -8
- package/package.json +1 -1
package/dist/storage/git.js
CHANGED
|
@@ -2,6 +2,7 @@ import { execSync } from 'child_process';
|
|
|
2
2
|
import { statSync } from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
// Git utilities for repository detection, commit tracking, and diff analysis
|
|
5
|
+
const chompGitOutput = (value) => value.toString().replace(/\r?\n$/, '');
|
|
5
6
|
export const isGitRepo = (repoPath) => {
|
|
6
7
|
try {
|
|
7
8
|
execSync('git rev-parse --is-inside-work-tree', {
|
|
@@ -99,14 +100,12 @@ export const getRemoteUrl = (repoPath) => {
|
|
|
99
100
|
*/
|
|
100
101
|
export const getGitRoot = (fromPath) => {
|
|
101
102
|
try {
|
|
102
|
-
const raw = execSync('git rev-parse --show-toplevel', {
|
|
103
|
+
const raw = chompGitOutput(execSync('git rev-parse --show-toplevel', {
|
|
103
104
|
cwd: fromPath,
|
|
104
105
|
// Suppress stderr -- see getCurrentCommit comment and #1172.
|
|
105
106
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
106
107
|
windowsHide: true,
|
|
107
|
-
})
|
|
108
|
-
.toString()
|
|
109
|
-
.trim();
|
|
108
|
+
}));
|
|
110
109
|
// On Windows, git returns /d/Projects/Foo — path.resolve normalizes to D:\Projects\Foo
|
|
111
110
|
return path.resolve(raw);
|
|
112
111
|
}
|
|
@@ -143,13 +142,11 @@ export const getGitRoot = (fromPath) => {
|
|
|
143
142
|
*/
|
|
144
143
|
export const getCanonicalRepoRoot = (fromPath) => {
|
|
145
144
|
try {
|
|
146
|
-
const commonDir = execSync('git rev-parse --path-format=absolute --git-common-dir', {
|
|
145
|
+
const commonDir = chompGitOutput(execSync('git rev-parse --path-format=absolute --git-common-dir', {
|
|
147
146
|
cwd: fromPath,
|
|
148
147
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
149
148
|
windowsHide: true,
|
|
150
|
-
})
|
|
151
|
-
.toString()
|
|
152
|
-
.trim();
|
|
149
|
+
}));
|
|
153
150
|
if (!commonDir)
|
|
154
151
|
return null;
|
|
155
152
|
// Common dir is `<repo>/.git` for both the main checkout and all
|
package/package.json
CHANGED