-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: bail on incompatible git versions
- Loading branch information
Eli Skeggs
committed
Jan 31, 2020
1 parent
9a17d65
commit 0a8eecc
Showing
4 changed files
with
49 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,3 +1,18 @@ | ||
import execa from 'execa'; | ||
import semver from 'semver'; | ||
|
||
export const git = (...args) => execa('git', args).then(({ stdout }) => stdout); | ||
|
||
async function getGitVersion() { | ||
// This produces a string like "git version 2.25.0" | ||
const version = await git('version'); | ||
return version.slice(version.lastIndexOf(' ') + 1); | ||
} | ||
|
||
export async function getCurrentBranch() { | ||
if (semver.lt(await getGitVersion(), '2.22.0')) { | ||
throw new Error('please upgrade git to at least 2.22.0'); | ||
} | ||
|
||
return git('branch', '--show-current'); | ||
} |
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