Skip to content

Commit dde1fe5

Browse files
authored
Merge branch 'main' into issue-601
2 parents 702b7d1 + f1d548f commit dde1fe5

File tree

4 files changed

+34
-10
lines changed

4 files changed

+34
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4949
- Fixed suppressing editing of locked classes (#301)
5050
- Fixed importing CSP files (#251)
5151
- Fixed changing favorites for users without permissions (#587)
52+
- Fix creating new branch from Git Web UI (#591)
5253
- Fix wording for Git Repo Root Directory (#601)
5354

5455
## [2.6.0] - 2024-10-07

cls/SourceControl/Git/WebUIDriver.cls

Lines changed: 17 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,21 @@ 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+
set branchName = $get(%request.Data("branch",1),"")
334+
if (branchName = "") {
335+
do %data.Write("ERROR! Enter a valid branch name")
336+
} else {
337+
set %data = ##class(%Stream.TmpCharacter).%New()
338+
339+
set st = ##class(SourceControl.Git.Utils).NewBranch(branchName)
340+
if $$$ISERR(st) {
341+
do %data.Write("Error! "_$System.Status.GetErrorText(st))
342+
} else {
343+
do %data.Write(branchName_" branch created!")
344+
}
345+
set handled = 1
346+
}
331347
}
332348
}
333349
}
@@ -426,4 +442,3 @@ ClassMethod GetRemote() As %Library.DynamicObject
426442
}
427443

428444
}
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+
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+
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+
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+
updateSideBar();
593+
});
590594
}
591595
});
592596
});

0 commit comments

Comments
 (0)