Skip to content

Commit 7e9e0e0

Browse files
committed
Creating branches is now consistent
1 parent 90c0853 commit 7e9e0e0

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

cls/SourceControl/Git/WebUIDriver.cls

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out
102102
do %request.Set("EXPIRES",0)
103103
do ##class(%CSP.StreamServer).OnPreHTTP() // Need to call this to set headers properly
104104
set %stream = 1 // Leak this to webuidriver.csp
105-
} elseif $match(pathStart,"git-command|git|dirname|hostname|viewonly|discarded-states|restore-discarded|contexts") {
105+
} elseif $match(pathStart,"git-command|git|dirname|hostname|viewonly|discarded-states|restore-discarded|contexts|create-branch") {
106106
if (%request.Method = "GET") {
107107
set %data = ##class(%Stream.TmpCharacter).%New()
108108
// Things not handled from Python backend:
@@ -218,6 +218,7 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out
218218
} else {
219219
set inFile = ""
220220
}
221+
221222
set returnCode = ##class(SourceControl.Git.Utils).RunGitCommandWithInput("-c",inFile,.errStream,.outStream,gitArgs...)
222223

223224
set %data = ##class(%Stream.TmpCharacter).%New()
@@ -328,6 +329,18 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out
328329
do %data.Rewind()
329330
do ##class(SourceControl.Git.Change).RefreshUncommitted(,,,1)
330331
set handled = 1
332+
} elseif (pathStart = "create-branch") {
333+
merge data = %request.Data
334+
set branchName = data("branch",1)
335+
336+
set %data = ##class(%Stream.TmpCharacter).%New()
337+
338+
set st = ##class(SourceControl.Git.Utils).NewBranch(branchName)
339+
if $$$ISERR(st) {
340+
do %data.Write("Error! "_st)
341+
} else {
342+
do %data.Write(branchName_" branch created!")
343+
}
331344
}
332345
}
333346
}
@@ -426,4 +439,3 @@ ClassMethod GetRemote() As %Library.DynamicObject
426439
}
427440

428441
}
429-

git-webui/release/share/git-webui/webui/js/git-webui.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,17 +576,21 @@ webui.SideBarView = function(mainView, noEventHandlers) {
576576
$("#confirm-branch-checkout").on('click', '#confirm-checkout', function(e){
577577
e.preventDefault();
578578
var refName = $("#confirm-branch-checkout pre")[0].innerHTML;
579-
580-
webui.git("checkout -b " + refName, updateSideBar);
581-
removeModal("#confirm-branch-checkout");
579+
580+
$.post('create-branch', {branch: refName}, function() {
581+
this.updateSideBar();
582+
removeModal("#confirm-branch-checkout");
583+
});
582584
});
583585

584586
$("#confirm-branch-checkout").find("#cancel-checkout, .close").click(function() {
585587
removeModal("#confirm-branch-checkout");
586588
});
587589
}
588590
else{
589-
webui.git("checkout -b " + refName, updateSideBar);
591+
$.post('create-branch', {branch: refName}, function() {
592+
this.updateSideBar();
593+
});
590594
}
591595
});
592596
});

git-webui/src/share/git-webui/webui/js/git-webui.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,17 +576,21 @@ webui.SideBarView = function(mainView, noEventHandlers) {
576576
$("#confirm-branch-checkout").on('click', '#confirm-checkout', function(e){
577577
e.preventDefault();
578578
var refName = $("#confirm-branch-checkout pre")[0].innerHTML;
579-
580-
webui.git("checkout -b " + refName, updateSideBar);
581-
removeModal("#confirm-branch-checkout");
579+
580+
$.post('create-branch', {branch: refName}, function() {
581+
this.updateSideBar();
582+
removeModal("#confirm-branch-checkout");
583+
});
582584
});
583585

584586
$("#confirm-branch-checkout").find("#cancel-checkout, .close").click(function() {
585587
removeModal("#confirm-branch-checkout");
586588
});
587589
}
588590
else{
589-
webui.git("checkout -b " + refName, updateSideBar);
591+
$.post('create-branch', {branch: refName}, function() {
592+
this.updateSideBar();
593+
});
590594
}
591595
});
592596
});

0 commit comments

Comments
 (0)