1
0
Fork 0
mirror of https://github.com/actions/checkout.git synced 2025-03-31 05:20:06 +02:00

fix issue checking detached when git less than 2.22

This commit is contained in:
eric sciple 2020-01-02 14:06:58 -05:00
parent c85684db76
commit 44e1b123fc
2 changed files with 9 additions and 11 deletions

8
dist/index.js vendored
View file

@ -4887,11 +4887,9 @@ class GitCommandManager {
}
isDetached() {
return __awaiter(this, void 0, void 0, function* () {
// Note, this implementation uses "branch --show-current" because
// "rev-parse --symbolic-full-name HEAD" can fail on a new repo
// with nothing checked out.
const output = yield this.execGit(['branch', '--show-current']);
return output.stdout.trim() === '';
// Note, "branch --show-current" would be simpler but isn't available until Git 2.22
const output = yield this.execGit(['rev-parse', '--symbolic-full-nane', 'HEAD'], true);
return !output.stdout.trim().startsWith('refs/heads/');
});
}
lfsFetch(ref) {

View file

@ -170,12 +170,12 @@ class GitCommandManager {
}
async isDetached(): Promise<boolean> {
// Note, this implementation uses "branch --show-current" because
// "rev-parse --symbolic-full-name HEAD" can fail on a new repo
// with nothing checked out.
const output = await this.execGit(['branch', '--show-current'])
return output.stdout.trim() === ''
// Note, "branch --show-current" would be simpler but isn't available until Git 2.22
const output = await this.execGit(
['rev-parse', '--symbolic-full-nane', 'HEAD'],
true
)
return !output.stdout.trim().startsWith('refs/heads/')
}
async lfsFetch(ref: string): Promise<void> {