Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue checking detached when git less than 2.22 #128

Merged
merged 4 commits into from Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions dist/index.js
Expand Up @@ -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/');
ericsciple marked this conversation as resolved.
Show resolved Hide resolved
});
}
lfsFetch(ref) {
Expand Down
12 changes: 6 additions & 6 deletions src/git-command-manager.ts
Expand Up @@ -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> {
Expand Down