-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: retrieve
branch
from repo with a detached head
- Loading branch information
Showing
5 changed files
with
88 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,24 @@ | ||
import test from 'ava'; | ||
import git from '../lib/git'; | ||
import {gitRepo, gitCommit} from './helpers/git-utils'; | ||
import {gitRepo, gitCommit, gitHead} from './helpers/git-utils'; | ||
|
||
// Save the current working diretory | ||
const cwd = process.cwd(); | ||
|
||
test.beforeEach(async () => { | ||
await gitRepo('master'); | ||
}); | ||
|
||
test.afterEach.always(() => { | ||
// Restore the current working directory | ||
process.chdir(cwd); | ||
}); | ||
|
||
test.serial('Git repository', async t => { | ||
await gitRepo(); | ||
const commit = await gitCommit(); | ||
|
||
t.deepEqual(git.configuration(), {commit, branch: 'master'}); | ||
}); | ||
|
||
test.serial('Git repository with detached head', async t => { | ||
await gitRepo(true); | ||
|
||
t.deepEqual(git.configuration(), {commit: await gitHead(), branch: 'master'}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters