Skip to content

Commit ad9b0a5

Browse files
committed
Fix checking out remote branches / uncommitted work
1 parent 686b195 commit ad9b0a5

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
- Added feedback to settings page (#550)
2222
- Fix "Home" navigation to point to current namespace (#548)
2323
- Fixed issues when user checks out nonexistent branch (#549)
24+
- Fixed checking out branch with uncommitted work (#539)
2425

2526
## [2.6.0] - 2024-10-07
2627

cls/SourceControl/Git/Utils.cls

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,15 +403,20 @@ ClassMethod NewBranch(newBranchName As %String) As %Status
403403

404404
ClassMethod SwitchBranch(targetBranchName As %String) As %Status
405405
{
406-
// Make sure that branch exists first
407-
do ..RunGitWithArgs(.errStream,.outStream,"local-branches","branch", "--verbose")
406+
// Make sure that branch exists first (-a lists both local and remote)
407+
do ..RunGitWithArgs(.errStream,.outStream,"branch", "-a")
408408
set branches = outStream.Read()
409409
if ('$find(branches,targetBranchName)) {
410410
quit $$$ERROR($$$GeneralError, "Selected branch does not exist"_$C(10))
411411
}
412412
k outStream, errStream
413413
do ..RunGitWithArgs(.errStream, .outStream, "checkout", targetBranchName)
414414
do ..PrintStreams(errStream, outStream)
415+
// Checkout can fail due to unstaged changes
416+
set errs = errStream.Read()
417+
if (errs '= "") {
418+
quit $$$ERROR($$$GeneralError, errs)
419+
}
415420
quit $$$OK
416421
}
417422

0 commit comments

Comments
 (0)