Skip to content

Commit 3e8a0f4

Browse files
authored
Merge pull request #572 from intersystems/fix-534
fix: report errors creating new branches
2 parents afe2a42 + 558935a commit 3e8a0f4

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3535
- Fix branches with special characters not showing in GitUI (#523)
3636
- Fix filenames with spaces not showing correctly in workspace view (#551)
3737
- Removed inaccurate placeholder text for commit message in UI (#406)
38+
- Report error more clearly if you try to create a branch with an invalid name (#534)
3839

3940
## [2.6.0] - 2024-10-07
4041

cls/SourceControl/Git/Utils.cls

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Targe
319319

320320
ClassMethod AfterUserAction(Type As %Integer, Name As %String, InternalName As %String, Answer As %Integer, Msg As %String = "", ByRef Reload As %Boolean) As %Status
321321
{
322+
set status = $$$OK
322323
#dim menuName as %String = $piece(Name,",")
323324
#dim menuItemName as %String = $piece(Name,",",2)
324325
if (menuItemName = "Revert") || (menuItemName [ "Import") {
@@ -331,15 +332,12 @@ ClassMethod AfterUserAction(Type As %Integer, Name As %String, InternalName As %
331332
}
332333
} elseif (menuItemName = "NewBranch") {
333334
if (Answer = 1) {
334-
do ..NewBranch(Msg)
335+
set status = ..NewBranch(Msg)
335336
set Reload = 1
336337
}
337338
} elseif (menuItemName = "SwitchBranch") {
338339
if (Answer = 1) {
339340
set status = ..SwitchBranch(Msg)
340-
if $$$ISERR(status) {
341-
Quit status
342-
}
343341
set Reload = 1
344342
}
345343
} elseif (menuItemName = "Sync") {
@@ -356,7 +354,7 @@ ClassMethod AfterUserAction(Type As %Integer, Name As %String, InternalName As %
356354
// Always force reload as many things could have possibly changed.
357355
set Reload = 1
358356
}
359-
quit $$$OK
357+
quit status
360358
}
361359

362360
ClassMethod Init() As %Status
@@ -405,8 +403,12 @@ ClassMethod NewBranch(newBranchName As %String) As %Status
405403
kill errStream, outStream
406404
}
407405

408-
do ..RunGitWithArgs(.errStream, .outStream, "checkout", "-b", newBranchName)
406+
set err = ..RunGitWithArgs(.errStream, .outStream, "checkout", "-b", newBranchName)
409407
do ..PrintStreams(errStream, outStream)
408+
if err {
409+
do errStream.Rewind()
410+
quit $$$ERROR($$$GeneralError,errStream.Read()_$c(10)_"Current branch is: "_..GetCurrentBranch())
411+
}
410412
quit $$$OK
411413
}
412414

0 commit comments

Comments
 (0)