improvement: Review snapshot behavior (#95)

* Improve git tag detection (#77)
* Only handle snapshot flag for release cmd (#94)
* Use core.info instead of console.log
* Update gitattributes
This commit is contained in:
CrazyMax 2020-02-11 13:52:06 +01:00 committed by GitHub
parent 81d25e3b66
commit e198786300
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 123 additions and 30 deletions

25
src/git.ts Normal file
View file

@ -0,0 +1,25 @@
import * as child_process from 'child_process';
const git = async (args: string[] = []) => {
const stdout = child_process.execSync(`git ${args.join(' ')}`, {
encoding: 'utf8'
});
return stdout.trim();
};
export async function isTagDirty(currentTag: string): Promise<boolean> {
try {
await git(['describe', '--exact-match', '--tags', '--match', currentTag]);
} catch (err) {
return true;
}
return false;
}
export async function getTag(): Promise<string> {
return await git(['describe', '--tags', '--abbrev=0']);
}
export async function getShortCommit(): Promise<string> {
return await git(['show', "--format='%h'", 'HEAD', '--quiet']);
}