Skip to content

Commit 5be6e34

Browse files
committed
Merge pull request #302 from FezVrasta/localBranchDeletion
Added confirm dialog before local branch deletion.
2 parents ece033e + 699de22 commit 5be6e34

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

nls/root/strings.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ define({
4949
DELETE_FILE: "Delete file",
5050
DELETE_REMOTE: "Delete remote",
5151
DELETE_REMOTE_NAME: "Do you really wish to delete remote \"{0}\"?",
52+
DELETE_LOCAL_BRANCH: "Delete local branch",
53+
DELETE_LOCAL_BRANCH_NAME: "Do you really wish to delete local branch \"{0}\"?",
5254
DIFF: "Diff",
5355
DIFF_FAILED_SEE_FILES: "Git diff failed to provide diff results. This is the list of staged files to be commited:",
5456
ENTER_PASSWORD: "Enter password:",

src/Branch.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ define(function (require, exports) {
1111
FileSystem = brackets.getModule("filesystem/FileSystem"),
1212
Menus = brackets.getModule("command/Menus"),
1313
PopUpManager = brackets.getModule("widgets/PopUpManager"),
14+
StringUtils = brackets.getModule("utils/StringUtils"),
1415
SidebarView = brackets.getModule("project/SidebarView");
1516

1617
var Git = require("src/Git/Git"),
@@ -164,9 +165,24 @@ define(function (require, exports) {
164165
}).on("mouseleave", "a", function () {
165166
$(this).removeClass("selected");
166167
}).on("click", "a.git-branch-link .trash-icon", function () {
167-
Main.gitControl.deleteLocalBranch($(this).parent().data("branch")).catch(function (err) {
168-
ErrorHandler.showError(err, "Branch deletion failed");
168+
var branchName = $(this).parent().data("branch");
169+
Utils.askQuestion(
170+
Strings.DELETE_LOCAL_BRANCH,
171+
StringUtils.format(Strings.DELETE_LOCAL_BRANCH_NAME, branchName),
172+
{ booleanResponse: true }
173+
)
174+
.then(function (response) {
175+
if (response === true) {
176+
return Main.gitControl.deleteLocalBranch(branchName).catch(function (err) {
177+
ErrorHandler.showError(err, "Branch deletion failed");
178+
});
179+
}
180+
})
181+
.catch(function (err) {
182+
ErrorHandler.logError(err);
169183
});
184+
185+
170186
}).on("click", ".merge-branch", function () {
171187
var fromBranch = $(this).parent().data("branch");
172188
doMerge(fromBranch);

0 commit comments

Comments
 (0)