mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 00:40:07 +02:00
Added support for git tag -d <tag> and fixed a bug where a duplicate tag name wouldn't show in the error-msg
This commit is contained in:
parent
251ec17ed9
commit
b281d1d76c
3 changed files with 53 additions and 1 deletions
|
@ -811,8 +811,41 @@ var commandConfig = {
|
||||||
|
|
||||||
tag: {
|
tag: {
|
||||||
regex: /^git +tag($|\s)/,
|
regex: /^git +tag($|\s)/,
|
||||||
|
options: [
|
||||||
|
'-d'
|
||||||
|
],
|
||||||
execute: function(engine, command) {
|
execute: function(engine, command) {
|
||||||
var generalArgs = command.getGeneralArgs();
|
var generalArgs = command.getGeneralArgs();
|
||||||
|
var commandOptions = command.getOptionsMap();
|
||||||
|
|
||||||
|
if (commandOptions['-d']) {
|
||||||
|
var tagID = commandOptions['-d'];
|
||||||
|
var tagToRemove;
|
||||||
|
|
||||||
|
assertIsRef(engine, tagID);
|
||||||
|
|
||||||
|
command.oneArgImpliedHead(tagID);
|
||||||
|
engine.tagCollection.each(function(tag) {
|
||||||
|
if(tag.get('id') == tagID){
|
||||||
|
tagToRemove = tag;
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
if(tagToRemove == undefined){
|
||||||
|
throw new GitError({
|
||||||
|
msg: intl.todo(
|
||||||
|
'No tag found, nothing to remove'
|
||||||
|
)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
engine.tagCollection.remove(tagToRemove);
|
||||||
|
delete engine.refs[tagID];
|
||||||
|
|
||||||
|
engine.gitVisuals.refreshTree();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (generalArgs.length === 0) {
|
if (generalArgs.length === 0) {
|
||||||
var tags = engine.getTags();
|
var tags = engine.getTags();
|
||||||
engine.printTags(tags);
|
engine.printTags(tags);
|
||||||
|
|
|
@ -686,7 +686,7 @@ GitEngine.prototype.validateAndMakeTag = function(id, target) {
|
||||||
throw new GitError({
|
throw new GitError({
|
||||||
msg: intl.str(
|
msg: intl.str(
|
||||||
'bad-tag-name',
|
'bad-tag-name',
|
||||||
{ tag: name }
|
{ tag: id }
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -701,6 +701,25 @@ GitVisuals.prototype.addTagFromEvent = function(tag, collection, index) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GitVisuals.prototype.removeTag = function(tag, collection, index) {
|
||||||
|
var action = function() {
|
||||||
|
var tagToRemove;
|
||||||
|
this.visTagCollection.each(function(visTag) {
|
||||||
|
if(visTag.get('tag') == tag){
|
||||||
|
tagToRemove = visTag;
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
tagToRemove.remove();
|
||||||
|
this.removeVisTag(tagToRemove);
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
|
if (!this.gitEngine || !this.gitReady) {
|
||||||
|
this.defer(action);
|
||||||
|
} else {
|
||||||
|
action();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
GitVisuals.prototype.addTag = function(tag) {
|
GitVisuals.prototype.addTag = function(tag) {
|
||||||
var visTag = new VisTag({
|
var visTag = new VisTag({
|
||||||
tag: tag,
|
tag: tag,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue