diff --git a/dist/index.js b/dist/index.js index 01dfa96..57828d7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -158,9 +158,8 @@ function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName throw new Error(`Unexpected error: ${commitResult.stderr}`); } } - // Remove uncommitted tracked and untracked changes - yield git.exec(['reset', '--hard']); - yield git.exec(['clean', '-f', '-d']); + // Stash any uncommitted tracked and untracked changes + const stashed = yield git.stashPush(['--include-untracked']); // Perform fetch and reset the working base // Commits made during the workflow will be removed if (workingBaseType == WorkingBaseType.Branch) { @@ -258,6 +257,12 @@ function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName result.headSha = yield git.revParse('HEAD'); // Delete the temporary branch yield git.exec(['branch', '--delete', '--force', tempBranch]); + // Checkout the working base to leave the local repository as it was found + yield git.checkout(workingBase); + // Restore any stashed changes + if (stashed) { + yield git.stashPop(); + } return result; }); } @@ -426,7 +431,7 @@ function createPullRequest(inputs) { yield git.push([ '--force-with-lease', branchRemoteName, - `HEAD:refs/heads/${inputs.branch}` + `${inputs.branch}:refs/heads/${inputs.branch}` ]); core.endGroup(); } @@ -842,6 +847,25 @@ class GitCommandManager { return output.stdout.trim(); }); } + stashPush(options) { + return __awaiter(this, void 0, void 0, function* () { + const args = ['stash', 'push']; + if (options) { + args.push(...options); + } + const output = yield this.exec(args); + return output.stdout.trim() !== 'No local changes to save'; + }); + } + stashPop(options) { + return __awaiter(this, void 0, void 0, function* () { + const args = ['stash', 'pop']; + if (options) { + args.push(...options); + } + yield this.exec(args); + }); + } status(options) { return __awaiter(this, void 0, void 0, function* () { const args = ['status']; diff --git a/report.txt b/report.txt new file mode 100644 index 0000000..6829889 --- /dev/null +++ b/report.txt @@ -0,0 +1 @@ +1669702280