From 98620f54554fa801fce71f6547ff2b29b9967c37 Mon Sep 17 00:00:00 2001 From: peter-evans Date: Tue, 17 Nov 2020 02:45:59 +0000 Subject: [PATCH] [CI] test committed --- dist/index.js | 39 ++++++++++++++++----------------------- report.txt | 1 + 2 files changed, 17 insertions(+), 23 deletions(-) create mode 100644 report.txt diff --git a/dist/index.js b/dist/index.js index 2018a13..e1a6acd 100644 --- a/dist/index.js +++ b/dist/index.js @@ -93,12 +93,6 @@ function isEven(git, branch1, branch2) { !(yield isBehind(git, branch1, branch2))); }); } -function hasDiff(git, branch1, branch2) { - return __awaiter(this, void 0, void 0, function* () { - const result = yield git.diff([`${branch1}..${branch2}`]); - return result.length > 0; - }); -} function splitLines(multilineString) { return multilineString .split('\n') @@ -192,7 +186,7 @@ function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName // squash merged but not deleted. We need to reset to make sure it doesn't appear // to have a diff with the base due to different commits for the same changes. // For changes on base this reset is equivalent to a rebase of the pull request branch. - if ((yield hasDiff(git, branch, tempBranch)) || + if ((yield git.hasDiff([`${branch}..${tempBranch}`])) || !(yield isAhead(git, base, tempBranch))) { core.info(`Resetting '${branch}'`); // Alternatively, git switch -C branch tempBranch @@ -662,16 +656,6 @@ class GitCommandManager { return output.exitCode === 0; }); } - diff(options) { - return __awaiter(this, void 0, void 0, function* () { - const args = ['-c', 'core.pager=cat', 'diff']; - if (options) { - args.push(...options); - } - const output = yield this.exec(args); - return output.stdout.trim(); - }); - } fetch(refSpec, remoteName, options) { return __awaiter(this, void 0, void 0, function* () { const args = ['-c', 'protocol.version=2', 'fetch']; @@ -712,19 +696,28 @@ class GitCommandManager { getWorkingDirectory() { return this.workingDirectory; } + hasDiff(options) { + return __awaiter(this, void 0, void 0, function* () { + const args = ['diff', '--quiet']; + if (options) { + args.push(...options); + } + const output = yield this.exec(args, true); + return output.exitCode === 1; + }); + } isDirty(untracked) { return __awaiter(this, void 0, void 0, function* () { - const diffArgs = ['--abbrev=40', '--full-index', '--raw']; - // Check staged changes - if (yield this.diff([...diffArgs, '--staged'])) { + // Check untracked changes + if (untracked && (yield this.status(['--porcelain', '-unormal']))) { return true; } // Check working index changes - if (yield this.diff(diffArgs)) { + if (yield this.hasDiff()) { return true; } - // Check untracked changes - if (untracked && (yield this.status(['--porcelain', '-unormal']))) { + // Check staged changes + if (yield this.hasDiff(['--staged'])) { return true; } return false; diff --git a/report.txt b/report.txt new file mode 100644 index 0000000..806a08d --- /dev/null +++ b/report.txt @@ -0,0 +1 @@ +1605581159