mirror of
https://github.com/kahole/edamagit.git
synced 2024-08-15 18:20:30 +03:00
Compare commits
4 Commits
0fd309db0a
...
c9dd914b77
Author | SHA1 | Date | |
---|---|---|---|
|
c9dd914b77 | ||
|
dd36f9e471 | ||
|
e0faf63d85 | ||
|
dc5cd8ddf7 |
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "magit",
|
||||
"version": "0.6.60",
|
||||
"version": "0.6.61",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "magit",
|
||||
"version": "0.6.60",
|
||||
"version": "0.6.61",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vscode/iconv-lite-umd": "^0.7.0",
|
||||
|
@ -7,7 +7,7 @@
|
||||
"author": {
|
||||
"name": "Kristian Andersen Hole"
|
||||
},
|
||||
"version": "0.6.60",
|
||||
"version": "0.6.61",
|
||||
"engines": {
|
||||
"vscode": "^1.50.0"
|
||||
},
|
||||
|
@ -207,13 +207,59 @@ async function createNewSpinoff({ repository }: MenuState) {
|
||||
prompt: 'Name for new branch',
|
||||
});
|
||||
|
||||
if (newBranchName && newBranchName.length > 0) {
|
||||
const args = ['checkout', '-B', newBranchName];
|
||||
return gitRun(repository.gitRepository, args);
|
||||
} else {
|
||||
window.setStatusBarMessage(
|
||||
if (!newBranchName || newBranchName.length < 1) {
|
||||
return window.setStatusBarMessage(
|
||||
'No name given for new branch',
|
||||
Constants.StatusMessageDisplayTimeout
|
||||
);
|
||||
}
|
||||
|
||||
if (repository.branches.find(b => b.name === newBranchName)) {
|
||||
return window.setStatusBarMessage(
|
||||
`Cannot spin off ${newBranchName}. It already exists`,
|
||||
Constants.StatusMessageDisplayTimeout
|
||||
);
|
||||
}
|
||||
|
||||
const base = repository.HEAD?.name;
|
||||
|
||||
if (!base) {
|
||||
return window.setStatusBarMessage(
|
||||
'No branch checked out',
|
||||
Constants.StatusMessageDisplayTimeout
|
||||
);
|
||||
}
|
||||
|
||||
// Save current commit hash of base branch for later reference
|
||||
const baseCommit = repository.HEAD?.commit;
|
||||
|
||||
// Get upsteam branch commit hash of base branch
|
||||
const upstreamBranchCommit = repository.HEAD.upstreamRemote?.commit?.hash;
|
||||
|
||||
// Checkout new branch
|
||||
await gitRun(repository.gitRepository, ['checkout', '-b', newBranchName]);
|
||||
|
||||
if (baseCommit && upstreamBranchCommit && baseCommit !== upstreamBranchCommit) {
|
||||
// Find common ancestor of base branch and upstream branch
|
||||
const mergeBase = await repository.gitRepository.getMergeBase(baseCommit, upstreamBranchCommit);
|
||||
|
||||
// Reset the original branch to the common ancestor
|
||||
await gitRun(repository.gitRepository, [
|
||||
'update-ref',
|
||||
'-m',
|
||||
`"reset: moving to ${mergeBase}"`,
|
||||
`refs/heads/${base}`,
|
||||
mergeBase
|
||||
]);
|
||||
|
||||
window.setStatusBarMessage(
|
||||
`Branch ${base} was reset to ${mergeBase}`,
|
||||
Constants.StatusMessageDisplayTimeout
|
||||
);
|
||||
} else {
|
||||
window.setStatusBarMessage(
|
||||
`Branch ${base} not changed`,
|
||||
Constants.StatusMessageDisplayTimeout
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user