1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const execa = require("execa");
|
4 |
|
5 | async function isGitRepo() {
|
6 | try {
|
7 | await execa('git', ['rev-parse', '--git-dir']);
|
8 | }
|
9 | catch (_) {
|
10 | return false;
|
11 | }
|
12 | return true;
|
13 | }
|
14 | exports.isGitRepo = isGitRepo;
|
15 | async function getCurrentBranch() {
|
16 | const { stdout } = await execa('git', ['symbolic-ref', '--short', 'HEAD']);
|
17 | return stdout;
|
18 | }
|
19 | exports.getCurrentBranch = getCurrentBranch;
|
20 | async function isWorkingTreeClean() {
|
21 | try {
|
22 | const { stdout: status } = await execa('git', ['status', '--porcelain']);
|
23 | if (status !== '') {
|
24 | return false;
|
25 | }
|
26 | return true;
|
27 | }
|
28 | catch (_) {
|
29 | return false;
|
30 | }
|
31 | }
|
32 | exports.isWorkingTreeClean = isWorkingTreeClean;
|
33 | async function isRemoteHistoryClean() {
|
34 | let history;
|
35 | try {
|
36 | const { stdout } = await execa('git', ['rev-list', '--count', '--left-only', '@{u}...HEAD']);
|
37 | history = stdout;
|
38 | }
|
39 | catch (_) {
|
40 | history = null;
|
41 | }
|
42 | if (history && history !== '0') {
|
43 | return false;
|
44 | }
|
45 | return true;
|
46 | }
|
47 | exports.isRemoteHistoryClean = isRemoteHistoryClean;
|
48 |
|
\ | No newline at end of file |