git-push-time 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/npm-publish.yml +59 -32
- package/README.md +110 -112
- package/bin/index.js +321 -339
- package/lib/commands/edit-time.js +141 -141
- package/lib/commands/fix.js +113 -113
- package/lib/commands/github.js +429 -445
- package/lib/commands/pull.js +90 -90
- package/lib/commands/push.js +720 -720
- package/lib/config.js +220 -220
- package/lib/fix.js +286 -286
- package/lib/git.js +525 -516
- package/lib/github.js +322 -322
- package/lib/prompt-helpers.js +19 -20
- package/lib/secrets.js +92 -92
- package/lib/ui.js +1057 -1063
- package/lib/utils.js +120 -120
- package/package.json +36 -36
package/lib/commands/pull.js
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { selectBox } from '../prompt-helpers.js';
|
|
3
|
-
import {
|
|
4
|
-
checkGitInstalled,
|
|
5
|
-
isGitRepo,
|
|
6
|
-
getCurrentBranchStrict,
|
|
7
|
-
pullFromRemote,
|
|
8
|
-
resolveTargetDir
|
|
9
|
-
} from '../git.js';
|
|
10
|
-
import {
|
|
11
|
-
printSection,
|
|
12
|
-
printTargetDir,
|
|
13
|
-
printGitMissing,
|
|
14
|
-
printErrorBox,
|
|
15
|
-
printFooter
|
|
16
|
-
} from '../ui.js';
|
|
17
|
-
|
|
18
|
-
export async function runPullCommand(remote = 'origin', branch, options = {}) {
|
|
19
|
-
const fromMenu = options.fromMenu === true;
|
|
20
|
-
|
|
21
|
-
if (!checkGitInstalled()) {
|
|
22
|
-
printGitMissing();
|
|
23
|
-
if (fromMenu) return;
|
|
24
|
-
process.exit(1);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let targetDir = process.cwd();
|
|
28
|
-
if (options.dir) {
|
|
29
|
-
const r = resolveTargetDir(options.dir, process.cwd());
|
|
30
|
-
if (!r.ok) {
|
|
31
|
-
printErrorBox('
|
|
32
|
-
if (fromMenu) return;
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
targetDir = r.fullPath;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (!isGitRepo(targetDir)) {
|
|
39
|
-
printErrorBox('
|
|
40
|
-
if (fromMenu) return;
|
|
41
|
-
process.exit(1);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (!branch) {
|
|
45
|
-
branch = getCurrentBranchStrict(targetDir);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (!branch) {
|
|
49
|
-
printErrorBox('
|
|
50
|
-
if (fromMenu) return;
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const isInteractive = !options.yes;
|
|
55
|
-
try {
|
|
56
|
-
printSection(`PULL --
|
|
57
|
-
printTargetDir(targetDir);
|
|
58
|
-
const result = pullFromRemote(remote, branch, targetDir);
|
|
59
|
-
console.log(chalk.hex('#34D399')(` [OK] ${result || 'Repository
|
|
60
|
-
if (!fromMenu) printFooter();
|
|
61
|
-
} catch (error) {
|
|
62
|
-
printErrorBox('PULL
|
|
63
|
-
if (!isInteractive) {
|
|
64
|
-
if (fromMenu) return;
|
|
65
|
-
process.exit(1);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const choice = await selectBox({
|
|
69
|
-
message: '
|
|
70
|
-
hint: `git pull --rebase ${remote} ${branch}`,
|
|
71
|
-
choices: [
|
|
72
|
-
{ name: '
|
|
73
|
-
{ name: '
|
|
74
|
-
{ name: '
|
|
75
|
-
]
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
if (choice === 'rebase') {
|
|
79
|
-
try {
|
|
80
|
-
console.log(chalk.hex('#38BDF8')(`\n »
|
|
81
|
-
const out = pullFromRemote(remote, branch, targetDir, { rebase: true });
|
|
82
|
-
console.log(chalk.hex('#34D399')(` [OK] Pull --rebase
|
|
83
|
-
if (!fromMenu) printFooter();
|
|
84
|
-
} catch (rebaseErr) {
|
|
85
|
-
printErrorBox('PULL --REBASE
|
|
86
|
-
if (!fromMenu) process.exit(1);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { selectBox } from '../prompt-helpers.js';
|
|
3
|
+
import {
|
|
4
|
+
checkGitInstalled,
|
|
5
|
+
isGitRepo,
|
|
6
|
+
getCurrentBranchStrict,
|
|
7
|
+
pullFromRemote,
|
|
8
|
+
resolveTargetDir
|
|
9
|
+
} from '../git.js';
|
|
10
|
+
import {
|
|
11
|
+
printSection,
|
|
12
|
+
printTargetDir,
|
|
13
|
+
printGitMissing,
|
|
14
|
+
printErrorBox,
|
|
15
|
+
printFooter
|
|
16
|
+
} from '../ui.js';
|
|
17
|
+
|
|
18
|
+
export async function runPullCommand(remote = 'origin', branch, options = {}) {
|
|
19
|
+
const fromMenu = options.fromMenu === true;
|
|
20
|
+
|
|
21
|
+
if (!checkGitInstalled()) {
|
|
22
|
+
printGitMissing();
|
|
23
|
+
if (fromMenu) return;
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let targetDir = process.cwd();
|
|
28
|
+
if (options.dir) {
|
|
29
|
+
const r = resolveTargetDir(options.dir, process.cwd());
|
|
30
|
+
if (!r.ok) {
|
|
31
|
+
printErrorBox('INVALID DIRECTORY', [r.error]);
|
|
32
|
+
if (fromMenu) return;
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
targetDir = r.fullPath;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!isGitRepo(targetDir)) {
|
|
39
|
+
printErrorBox('NOT A GIT REPOSITORY', [`'${targetDir}' is not a Git repository.`]);
|
|
40
|
+
if (fromMenu) return;
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!branch) {
|
|
45
|
+
branch = getCurrentBranchStrict(targetDir);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!branch) {
|
|
49
|
+
printErrorBox('CANNOT DETERMINE BRANCH', ['HEAD is detached, so the branch to pull is unknown.'], 'Check out a branch and try again.');
|
|
50
|
+
if (fromMenu) return;
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const isInteractive = !options.yes;
|
|
55
|
+
try {
|
|
56
|
+
printSection(`PULL --FF-ONLY ${remote}/${branch}`);
|
|
57
|
+
printTargetDir(targetDir);
|
|
58
|
+
const result = pullFromRemote(remote, branch, targetDir);
|
|
59
|
+
console.log(chalk.hex('#34D399')(` [OK] ${result || 'Repository is up to date (fast-forward).'}\n`));
|
|
60
|
+
if (!fromMenu) printFooter();
|
|
61
|
+
} catch (error) {
|
|
62
|
+
printErrorBox('PULL FAILED', [String(error.message).split('\n')[0]], 'Fast-forward failed because the histories diverged. You can try pull --rebase.');
|
|
63
|
+
if (!isInteractive) {
|
|
64
|
+
if (fromMenu) return;
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const choice = await selectBox({
|
|
69
|
+
message: 'Fast-forward pull failed. What would you like to do?',
|
|
70
|
+
hint: `git pull --rebase ${remote} ${branch}`,
|
|
71
|
+
choices: [
|
|
72
|
+
{ name: 'Try pulling with rebase', value: 'rebase', description: `git pull --rebase ${remote} ${branch}` },
|
|
73
|
+
{ name: 'Go back', value: 'back', description: 'Return to the previous screen' },
|
|
74
|
+
{ name: 'Exit', value: 'exit', description: 'Stop here' }
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
if (choice === 'rebase') {
|
|
79
|
+
try {
|
|
80
|
+
console.log(chalk.hex('#38BDF8')(`\n » Running: git pull --rebase ${remote} ${branch}...`));
|
|
81
|
+
const out = pullFromRemote(remote, branch, targetDir, { rebase: true });
|
|
82
|
+
console.log(chalk.hex('#34D399')(` [OK] Pull --rebase succeeded. ${String(out).split('\n')[0].slice(0, 100)}\n`));
|
|
83
|
+
if (!fromMenu) printFooter();
|
|
84
|
+
} catch (rebaseErr) {
|
|
85
|
+
printErrorBox('PULL --REBASE FAILED', [String(rebaseErr.message).split('\n')[0]], 'There may be merge conflicts. Run git status to review them.');
|
|
86
|
+
if (!fromMenu) process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|