Skip to content

Commit 76ba8fa

Browse files
authored
Merge pull request #824 from cambot/bugfix/checkout-issue-823
Bugfix: checkout issue #823
2 parents d1c1e65 + 49b63a8 commit 76ba8fa

File tree

4 files changed

+34
-13
lines changed

4 files changed

+34
-13
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111
- Expanded Baseline Export to include XSL Transforms (#815)
12+
- Enhanced "Check out branch" to first refresh list of remote branches to eliminate failure due to stale information (#823)
1213

1314
### Fixed
1415
- Fix Import All not importing items that do not already exist when compileOnImport is not set (#798)
@@ -18,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1819
- Fix Revert not syncing files with IRIS (#789)
1920
- Import All now outputs a warning instead of an error when an item is in the wrong path (#291)
2021

22+
2123
## [2.12.2] - 2025-07-08
2224

2325
### Fixed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ We encourage use of [Conventional Commits](https://www.conventionalcommits.org/e
1414

1515
Generally speaking, just try to match the conventions you see in the code you are reading. For this project, these include:
1616

17-
* Do not use shortened command and function names. For example, use `set` instead of `s` instead of `set` and `$piece` instead of `$p`
17+
* Do not use shortened command and function names. For example, use `set` instead of `s` and `$piece` instead of `$p`
1818
* One command per line
1919
* Do not use dot syntax
2020
* Indentation with tabs

cls/SourceControl/Git/Utils.cls

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -443,13 +443,14 @@ ClassMethod NewBranch(newBranchName As %String) As %Status
443443

444444
ClassMethod SwitchBranch(targetBranchName As %String) As %Status
445445
{
446-
// Make sure that branch exists first (-a lists both local and remote)
447-
do ..RunGitWithArgs(.errStream,.outStream,"branch", "-a")
446+
// First, make sure that branch exists
447+
do ..RunGitCommand("fetch", .errStream, .outStream, "--prune") // refresh list of remote branches
448+
do ..RunGitWithArgs(.errStream, .outStream, "branch", "-a") // -a lists both local and remote
448449
set branches = outStream.Read()
449-
if ('$find(branches,targetBranchName)) {
450+
if ('$FIND(branches, targetBranchName)) {
450451
quit $$$ERROR($$$GeneralError, "Selected branch does not exist"_$C(10))
451452
}
452-
k outStream, errStream
453+
kill outStream, errStream
453454
do ..RunGitWithArgs(.errStream, .outStream, "checkout", targetBranchName)
454455
do ..PrintStreams(errStream, outStream)
455456
// Checkout can fail due to unstaged changes
@@ -1567,7 +1568,7 @@ ClassMethod ImportRoutines(force As %Boolean = 0, pullEventClass As %String) As
15671568

15681569
#dim ec as %Status = ..ListItemsInFiles(.itemList, .err)
15691570
quit:'ec ec
1570-
1571+
15711572
// If there is a config file it must be imported before everything else.
15721573
if $Data(itemList(##class(SourceControl.Git.Settings.Document).#INTERNALNAME)) {
15731574
set sc = ##class(SourceControl.Git.Utils).ImportItem(##class(SourceControl.Git.Settings.Document).#INTERNALNAME, force)
@@ -1591,10 +1592,10 @@ ClassMethod ImportRoutines(force As %Boolean = 0, pullEventClass As %String) As
15911592
for {
15921593
set internalName = $order(itemList(internalName))
15931594
quit:internalName=""
1594-
1595+
15951596
// Don't import the config file a second time
15961597
continue:internalName=##class(SourceControl.Git.Settings.Document).#INTERNALNAME
1597-
1598+
15981599
set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(internalName)
15991600
continue:context.Package'=refPackage
16001601
set doImport = ..IsRoutineOutdated(internalName) || force
@@ -2814,7 +2815,7 @@ ClassMethod GetSourceControlInclude(prefix As %String = {%request.URLPrefix}) As
28142815

28152816
XData ProductionConfigScript [ MimeType = text/javascript ]
28162817
{
2817-
function checkProductionConfigLoad() {
2818+
function checkProductionConfigLoad() {
28182819
timerState(false);
28192820
}
28202821

docs/menu-items.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# git-source-control Menu Items
22

3-
43
## Status
54
This menu option is analogous to the [git status](https://git-scm.com/docs/git-status) command and prints the status of the repository to the output.
5+
66
## Settings
77
This option opens the GUI's settings page project specific git-source-control settings can be configured. This includes the settings that were configured when running:
88
```
@@ -12,31 +12,49 @@ d ##class(SourceControl.Git.API).Configure()
1212
This page also includes the mappings configurations.
1313

1414
Any changes made to the settings must be saved using the 'Save' button in order to take effect.
15+
1516
## Launch Git UI
1617
This menu option opens the git-source-control GUI. From here commit messages can be written, files can be staged and committed, branches can be viewed.
18+
1719
## Add
1820
This menu option is analogous to the [git add](https://git-scm.com/docs/git-add) command. It will perform 'git add' on the currently open file, adding it to the files that can be staged.
21+
1922
## Remove
2023
This menu option will only appear if the currently open file has been already added using the 'Add' menu option. It undoes the effect of adding the file, similar to running [git reset](https://git-scm.com/docs/git-reset) on a specific file.
24+
2125
## Push to remote branch
2226
This option pushes the commits in the branch to the remote repository. This exhibits the same behavior as the [git push](https://git-scm.com/docs/git-push) command.
27+
2328
## Push to remote branch (force)
2429
This option forcibly pushes the commits in the branch to the remote repository. This is potentially destructive and may overwrite the commit history of the remote branch. This exhibits the same behavior as the [git push --force](https://git-scm.com/docs/git-push) command.
30+
2531
## Fetch from remote
26-
Much like the [git fetch](https://git-scm.com/docs/git-fetch) command, this option fetches the most recent versions of the branch without merging that version into the local copy of the branch.
32+
This option first [fetches](https://git-scm.com/docs/git-fetch) the most recent version of the branch without merging that version into the local copy of the branch. It will then list all files modified between the current version and the remote version.
33+
34+
This also has the effect of refreshing the list of all remote branches and pruning any references that no longer exist in the remote. (see: [git fetch --prune](https://git-scm.com/docs/git-fetch#Documentation/git-fetch.txt---prune))
35+
2736
## Pull changes from remote branch
2837
Much like the [git pull](https://git-scm.com/docs/git-pull) command, this menu option pulls the most recent version of the current branch from a remote source, merging the changes into the local copy.
38+
2939
## Sync
3040
This option will synchronize a local repo with the remote repo. The sync operation is only enabled in basic mode. It encapsulates the pattern of fetching, pulling, committing and then pushing into one menu action. If there is no defined remote repository, it will simply commit any uncommitted files.
41+
3142
## Create new branch
3243
This menu option creates a new branch in the repository for changes to be committed to. It also changes the current branch to be the created branch. This mimics the behavior of the [git checkout -b](https://git-scm.com/docs/git-checkout) command.
44+
3345
## Check out an existing branch
34-
This option changes the currently checkout branch to a chosen branch. This mimics the behavior of the [git checkout](https://git-scm.com/docs/git-checkout) command.
46+
This option refreshes the local list of branches available in the upstream repository, and then changes the currently checkedout branch to the provided branch. This mimics the behavior of the [git fetch --prune](https://git-scm.com/docs/git-fetch#Documentation/git-fetch.txt---prune) and [git checkout](https://git-scm.com/docs/git-checkout) commands.
47+
48+
If the desired branch does not exist in your local or in the remote, then you will receive the "Selected branch does not exist" error message.
49+
3550
## Export all
3651
This option exports class files to the local file tree at the configured location.
52+
3753
## Export all (force)
3854
This option exports all class files regardless of whether they're already up to date in the local file tree or not.
55+
3956
## Import all
4057
This option imports the versions of the files that are found in the configured directory into the project. Files that are out of date or the same as the files in the project won't be imported.
58+
4159
## Import all (force)
42-
This menu option behaves similarly to the regular import but forces the files to be imported regardless of whether the on-disk version is the same or older.
60+
This menu option behaves similarly to the regular import but forces the files to be imported regardless of whether the on-disk version is the same or older.

0 commit comments

Comments
 (0)