Skip to content

Commit 8115ba5

Browse files
authored
Add NotStagedChangesFound (#37)
* Handler error when not staged changes detected (#5) * Add NotStagedChangesFoundError (#14)
1 parent 7d2290f commit 8115ba5

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/git/client.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,17 @@ export default class Git {
267267
Logger.logInfo(`no local branch ${toBranch}`);
268268
}
269269

270-
await Git.fetch(upstreamBranch);
271-
Logger.logInfo(`git checkout ${Git.remote}/${upstreamBranch}`);
272-
await Git.git.checkout(`${Git.remote}/${upstreamBranch}`);
273-
Logger.logInfo(`git checkout -b ${toBranch}`);
274-
await Git.git.checkout(['-b', `${toBranch}`]);
275-
Logger.logInfo(`now at branch: ${await Git.getBranchName()}`);
270+
try {
271+
await Git.fetch(upstreamBranch);
272+
Logger.logInfo(`git checkout ${Git.remote}/${upstreamBranch}`);
273+
await Git.git.checkout(`${Git.remote}/${upstreamBranch}`);
274+
Logger.logInfo(`git checkout -b ${toBranch}`);
275+
await Git.git.checkout(['-b', `${toBranch}`]);
276+
Logger.logInfo(`now at branch: ${await Git.getBranchName()}`);
277+
} catch (e) {
278+
Logger.showNotStagedChangesFoundError(e.message.slice(7));
279+
throw e;
280+
}
276281
}
277282

278283
private static async cherryPick (firstCommit: string, lastCommit: string) {

src/info/Logger.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const ERRORS = {
1111
NoFirstCommitError: 'No first commit found. Check that a git repository is opened.',
1212
IncorrectBranchNameError: '"$" is not correct branch name. Name your branch as *branch__upstream*',
1313
NoCommitInBranchError: 'There is no new commits in "$" branch',
14-
NoLocalBranchError: 'Branch "$"does not exist. Did you forget to cherry-pick?'
14+
NoLocalBranchError: 'Branch "$"does not exist. Did you forget to cherry-pick?',
15+
NotStagedChangesFoundError: 'Not staged changes are found. $'
1516
};
1617

1718
const WARNINGS = {

0 commit comments

Comments
 (0)