Skip to content

Commit e358139

Browse files
committed
fixup! fix(git-node): use stash and detached head for release operations
1 parent 962c359 commit e358139

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

components/git/release.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,14 @@ function release(state, argv) {
123123
}
124124

125125
async function wrapStash(fn) {
126-
let stashed = false;
127-
try {
128-
await forceRunAsync('git', ['--no-pager', 'diff', '--exit-code'], { ignoreFailure: false });
129-
} catch {
130-
await forceRunAsync('git', ['stash', '--include-untracked'], { ignoreFailure: false });
131-
stashed = true;
132-
}
126+
const stashTip = await forceRunAsync('git', ['stash', 'list', '-1', '--format="%gd"'], { ignoreFailure: false, captureStdout: true });
127+
await forceRunAsync('git', ['stash', '--include-untracked'], { ignoreFailure: false });
128+
const newStashTip = await forceRunAsync('git', ['stash', 'list', '-1', '--format="%gd"'], { ignoreFailure: false, captureStdout: true });
129+
const hasStashed = newStashTip !== stashTip && newStashTip.trim();
133130
try {
134131
await fn();
135132
} finally {
136-
if (stashed) {
133+
if (hasStashed) {
137134
await forceRunAsync('git', ['stash', 'pop'], { ignoreFailure: false });
138135
}
139136
}

0 commit comments

Comments
 (0)