WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 42eafe5

Browse files
authored
Merge pull request #71 from gitleaks/fix/invalid-revision
fix-up invalid revision
2 parents 13c1edd + c7d343c commit 42eafe5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

dist/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69816,7 +69816,13 @@ async function Scan(gitleaksEnableUploadArtifact, scanInfo, eventType) {
6981669816
"--log-level=debug",
6981769817
];
6981869818
if (eventType == "pull_request" || eventType == "push") {
69819-
args.push(`--log-opts=${scanInfo.baseRef}^..${scanInfo.headRef}`);
69819+
if (scanInfo.baseRef == scanInfo.headRef) {
69820+
// if base and head refs are the same, use `--log-opts=-1` to
69821+
// scan only one commit
69822+
args.push(`--log-opts=-1`);
69823+
} else {
69824+
args.push(`--log-opts=${scanInfo.baseRef}^..${scanInfo.headRef}`);
69825+
}
6982069826
}
6982169827
core.info(`gitleaks cmd: gitleaks ${args.join(" ")}`);
6982269828
let exitCode = await exec.exec("gitleaks", args, {

src/gitleaks.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,13 @@ async function Scan(gitleaksEnableUploadArtifact, scanInfo, eventType) {
100100
"--log-level=debug",
101101
];
102102
if (eventType == "pull_request" || eventType == "push") {
103-
args.push(`--log-opts=${scanInfo.baseRef}^..${scanInfo.headRef}`);
103+
if (scanInfo.baseRef == scanInfo.headRef) {
104+
// if base and head refs are the same, use `--log-opts=-1` to
105+
// scan only one commit
106+
args.push(`--log-opts=-1`);
107+
} else {
108+
args.push(`--log-opts=${scanInfo.baseRef}^..${scanInfo.headRef}`);
109+
}
104110
}
105111
core.info(`gitleaks cmd: gitleaks ${args.join(" ")}`);
106112
let exitCode = await exec.exec("gitleaks", args, {

0 commit comments

Comments
 (0)