mirror of
https://github.com/github/codeql-action.git
synced 2026-10-30 01:27:22 +00:00
Merge remote-tracking branch 'origin/main' into mbg/improve-checkout-path
This commit is contained in:
@@ -34,10 +34,13 @@ test.serial(
|
||||
});
|
||||
|
||||
const callback = sinon.stub(gitUtils, "getCommitOid");
|
||||
callback.withArgs(sinon.match.any, "HEAD").resolves(currentSha);
|
||||
callback.withArgs(sinon.match.string, "HEAD").resolves(currentSha);
|
||||
|
||||
const actualRef = await gitUtils.getRef(env, tmpDir);
|
||||
t.deepEqual(actualRef, expectedRef);
|
||||
|
||||
t.is(callback.callCount, 1);
|
||||
t.true(callback.calledOnceWith(tmpDir, "HEAD"));
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -57,12 +60,16 @@ test.serial(
|
||||
|
||||
const callback = sinon.stub(gitUtils, "getCommitOid");
|
||||
callback
|
||||
.withArgs(sinon.match.any, "refs/remotes/pull/1/merge")
|
||||
.withArgs(sinon.match.string, "refs/remotes/pull/1/merge")
|
||||
.resolves(sha);
|
||||
callback.withArgs(sinon.match.any, "HEAD").resolves(sha);
|
||||
|
||||
const actualRef = await gitUtils.getRef(env, tmpDir);
|
||||
t.deepEqual(actualRef, expectedRef);
|
||||
|
||||
t.is(callback.callCount, 2);
|
||||
t.true(callback.calledWith(tmpDir, "HEAD"));
|
||||
t.true(callback.calledWith(tmpDir, "refs/remotes/pull/1/merge"));
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -80,14 +87,17 @@ test.serial(
|
||||
|
||||
const callback = sinon.stub(gitUtils, "getCommitOid");
|
||||
callback
|
||||
.withArgs(sinon.match.any, tmpDir, "refs/pull/1/merge")
|
||||
.withArgs(tmpDir, "refs/remotes/pull/1/merge")
|
||||
.resolves("a".repeat(40));
|
||||
callback
|
||||
.withArgs(sinon.match.any, tmpDir, "HEAD")
|
||||
.resolves("b".repeat(40));
|
||||
callback.withArgs(tmpDir, "HEAD").resolves("b".repeat(40));
|
||||
callback.throws(new Error("Unexpected getCommitOid call in test."));
|
||||
|
||||
const actualRef = await gitUtils.getRef(env, tmpDir);
|
||||
t.deepEqual(actualRef, "refs/pull/1/head");
|
||||
|
||||
t.is(callback.callCount, 2);
|
||||
t.true(callback.calledWith(tmpDir, "refs/remotes/pull/1/merge"));
|
||||
t.true(callback.calledWith(tmpDir, "HEAD"));
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -112,13 +122,14 @@ test.serial(
|
||||
});
|
||||
|
||||
const callback = sinon.stub(gitUtils, "getCommitOid");
|
||||
callback
|
||||
.withArgs(sinon.match.any, "refs/pull/1/merge")
|
||||
.resolves("b".repeat(40));
|
||||
callback.withArgs(tmpDir, "refs/pull/1/merge").resolves("b".repeat(40));
|
||||
callback.withArgs(sinon.match.any, "HEAD").resolves("b".repeat(40));
|
||||
|
||||
const actualRef = await gitUtils.getRef(env, tmpDir);
|
||||
t.deepEqual(actualRef, "refs/pull/2/merge");
|
||||
|
||||
// getCommitOid shouldn't be called, because the ref should be taken from the input
|
||||
t.is(callback.callCount, 0);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user