Skip to content

Commit c01f1bd

Browse files
committed
Merge branch 'main' into fix-124
2 parents 2fbb29f + 3faf8a7 commit c01f1bd

File tree

6 files changed

+56
-13
lines changed

6 files changed

+56
-13
lines changed

CHANGELOG.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,21 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [2.6.0] - Unreleased
8+
## [2.7.0] - Unreleased
9+
10+
### Added
11+
- Added 'git push --force' in expert mode (#527)
12+
- Added environment awareness in configuration, and showing of environment name in UI (#124)
13+
14+
## [2.6.0] - 2024-10-07
915

1016
### Added
1117
- Discards safeguarded by discard stash and warning modal (#455)
1218
- Files in uncommitted queue in any namespace warn users when opened except for in VSCode (#370)
1319
- Added link back to IRIS management portal from Settings, Git WebUI pages (#449)
1420
- Added Import all and Import All (Force) to basic mode menu (#498)
1521
- Improved behavior for commits when attribution settings are not configured (#450)
16-
- Added environment awareness in configuration, and showing of environment name in UI (#124)
22+
- Convert URLs in Sync output UI into clickable links (#497)
1723

1824
### Fixed
1925
- Changed prompts in configure from 0/1 to no/yes (#461)
@@ -24,6 +30,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2430
- Fetch diff output uses correct remote branch (#509)
2531
- Properly handle more cases of truncated filenames from git pull (#511)
2632
- Made git-source-control backwards compatible with IRIS 2021.1 (#513)
33+
- Sync, pull properly handle more change edge cases for import (#517, #496)
34+
- "Status" menu item actually includes branch when IRIS version allows (#472)
2735

2836
## [2.5.0] - 2024-09-24
2937

cls/SourceControl/Git/Extension.cls

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ XData Menu
2222
<MenuItem Separator="true"/>
2323
<MenuItem Name="Sync" />
2424
<MenuItem Name="Push" />
25+
<MenuItem Name="PushForce" />
2526
<MenuItem Name="Fetch" />
2627
<MenuItem Name="Pull" />
2728
<MenuItem Separator="true"/>
@@ -127,6 +128,7 @@ Method LocalizeName(name As %String) As %String
127128
"Commit":$$$Text("@Commit@Commit changes to file"),
128129
"Sync":$$$Text("@Sync@Sync"),
129130
"Push":$$$Text("@Push@Push to remote branch"),
131+
"PushForce":$$$Text("@PushForce@Push to remote branch (Force)"),
130132
"Fetch":$$$Text("@Fetch@Fetch from remote"),
131133
"Pull":$$$Text("@Pull@Pull changes from remote branch"),
132134
"Status": $$$Text("@Status@Status"),
@@ -174,6 +176,7 @@ Method OnSourceMenuItem(name As %String, ByRef Enabled As %String, ByRef Display
174176
"NewBranch": 1,
175177
"SwitchBranch": 1,
176178
"Push": 1,
179+
"PushForce": 1,
177180
"Fetch": 1,
178181
"Pull": 1,
179182
"Sync": -1,
@@ -194,7 +197,7 @@ Method OnSourceMenuItem(name As %String, ByRef Enabled As %String, ByRef Display
194197

195198
if (name = "Status") {
196199
set DisplayName = ..LocalizeName(name)_" (branch: "_##class(SourceControl.Git.Utils).GetCurrentBranch()_")"
197-
} if (name '= "") {
200+
} elseif (name '= "") {
198201
set DisplayName = ..LocalizeName(name)
199202
}
200203
quit $$$OK

cls/SourceControl/Git/Utils.cls

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,10 @@ ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Targe
282282
quit $$$OK
283283
} elseif (menuItemName = "Push") {
284284
quit ..Push()
285+
} elseif (menuItemName = "PushForce") {
286+
set Target = "Force pushing is potentially destructive and may overwrite the commit history of the remote branch. Are you sure you want to proceed?"
287+
set Action = 1 // Make sure the user confirms that they want to do this
288+
quit $$$OK
285289
} elseif (menuItemName = "Fetch") {
286290
$$$QuitOnError(..Fetch(.diffFiles))
287291
set pointer = 0
@@ -331,6 +335,11 @@ ClassMethod AfterUserAction(Type As %Integer, Name As %String, InternalName As %
331335
do ..Sync(Msg)
332336
set Reload = 1
333337
}
338+
} elseif (menuItemName = "PushForce") {
339+
if (Answer = 1) {
340+
do ..Push(,1)
341+
set Reload = 1
342+
}
334343
} elseif (menuItemName = "GitWebUI") {
335344
// Always force reload as many things could have possibly changed.
336345
set Reload = 1
@@ -457,8 +466,7 @@ ClassMethod MergeDefaultRemoteBranch(Output alert As %String = "") As %Boolean
457466
do ..RunGitWithArgs(.errStream, .outStream, "fetch", "origin", defaultMergeBranch_":"_defaultMergeBranch)
458467
do ..PrintStreams(errStream, outStream)
459468

460-
do ..RunGitWithArgs(,.outStream, "rev-parse", "HEAD")
461-
set startSha = outStream.ReadLine()
469+
set startSha = ..GetCurrentRevision()
462470

463471
// Start a transaction so code changes can be rolled back
464472
set initTLevel = $TLevel
@@ -566,6 +574,13 @@ ClassMethod GetCurrentBranch() As %String
566574
quit branchName
567575
}
568576

577+
ClassMethod GetCurrentRevision() As %String
578+
{
579+
do ##class(SourceControl.Git.Utils).RunGitCommandWithInput("rev-parse",,.errStream,.outStream,"HEAD")
580+
set revision = outStream.ReadLine(outStream.Size)
581+
quit revision
582+
}
583+
569584
ClassMethod Pull(remote As %String = "origin") As %Status
570585
{
571586
New %gitSCOutputFlag
@@ -1741,7 +1756,11 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
17411756
} elseif (command = "restore") {
17421757
// Leave diffCompare empty, this actually does the right thing.
17431758
set syncIrisWithDiff = 1
1744-
} elseif (command = "merge") || (command = "rebase") || (command = "pull") {
1759+
} elseif (command = "pull") {
1760+
set syncIrisWithDiff = 1
1761+
// The current revision, prior to the pull, will be compared against
1762+
set diffCompare = ..GetCurrentRevision()
1763+
} elseif (command = "merge") || (command = "rebase") {
17451764
set syncIrisWithCommand = 1
17461765
if $data(args) && $data(args(args),diffCompare) {
17471766
// no-op
@@ -1805,7 +1824,10 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
18051824
set syncIrisWithCommand = 0
18061825
}
18071826

1808-
if syncIrisWithDiff {
1827+
// If performing a pull don't perform a diff until after the pull has occured.
1828+
// This is to avoid a double fetch, as pull performs one for us and also to avoid a potential
1829+
// race condition if the remote changes between now and the pull actually being performed.
1830+
if syncIrisWithDiff && (command '= "pull") {
18091831
if diffBase = "" {
18101832
set diffBase = ..GetCurrentBranch()
18111833
}
@@ -1819,23 +1841,30 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
18191841
set outLog = ##class(%Library.File).TempFilename()
18201842
set errLog = ##class(%Library.File).TempFilename()
18211843

1822-
set command = $extract(..GitBinPath(),2,*-1)
1844+
set gitCommand = $extract(..GitBinPath(),2,*-1)
18231845

18241846
set baseArgs = "/STDOUT="_$$$QUOTE(outLog)_" /STDERR="_$$$QUOTE(errLog)_$case(inFile, "":"", :" /STDIN="_$$$QUOTE(inFile))
18251847
try {
18261848
// Inject instance manager directory as global git config home directory
18271849
// On Linux, this avoids trying to use /root/.config/git/attributes for global git config
18281850
set env("XDG_CONFIG_HOME") = ##class(%File).ManagerDirectory()
1829-
set returnCode = $zf(-100,"/ENV=env... "_baseArgs,command,newArgs...)
1851+
set returnCode = $zf(-100,"/ENV=env... "_baseArgs,gitCommand,newArgs...)
18301852
} catch e {
18311853
if $$$isWINDOWS {
1832-
set returnCode = $zf(-100,baseArgs,command,newArgs...)
1854+
set returnCode = $zf(-100,baseArgs,gitCommand,newArgs...)
18331855
} else {
18341856
// If can't inject XDG_CONFIG_HOME (older IRIS version), need /SHELL on Linux to avoid permissions errors trying to use root's config
1835-
set returnCode = $zf(-100,"/SHELL "_baseArgs,command,newArgs...)
1857+
set returnCode = $zf(-100,"/SHELL "_baseArgs,gitCommand,newArgs...)
18361858
}
18371859
}
18381860

1861+
// If performing a pull then do a diff now after the pull has occured.
1862+
if syncIrisWithDiff && (command = "pull") {
1863+
do ##class(SourceControl.Git.Utils).RunGitCommandWithInput("diff",,.errorStream,.outputStream, diffCompare, "--name-status")
1864+
// Verbose output should not be required as pull already outputs a summary
1865+
do ..ParseDiffStream(outputStream,0,.files)
1866+
}
1867+
18391868
set errStream = ##class(%Stream.FileCharacter).%OpenId(errLog,,.sc)
18401869
set outStream = ##class(%Stream.FileCharacter).%OpenId(outLog,,.sc)
18411870
set outStream.TranslateTable="UTF8"

csp/sync.csp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@
147147
&js<
148148
var outputContainer = document.getElementById('outputBox');
149149
var lineText = #(..QuoteJS(escapedLine))#;
150-
var lineTextNode = document.createTextNode(lineText);
150+
var urlRegex = /(https?:\/\/[^ ]*)/gi;
151+
lineText = lineText.replace(urlRegex, "<a href='$1' target=_blank>$1</a>");
151152
outputContainer.innerHTML += lineText + "<br>";
152153
>
153154
}

docs/menu-items.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ This menu option is analogous to the [git add](https://git-scm.com/docs/git-add)
2020
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.
2121
## Push to remote branch
2222
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.
23+
## Push to remote branch (force)
24+
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.
2325
## Fetch from remote
2426
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.
2527
## Pull changes from remote branch

module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Document name="git-source-control.ZPM">
44
<Module>
55
<Name>git-source-control</Name>
6-
<Version>2.6.0</Version>
6+
<Version>2.7.0</Version>
77
<Description>Server-side source control extension for use of Git on InterSystems platforms</Description>
88
<Keywords>git source control studio vscode</Keywords>
99
<Packaging>module</Packaging>

0 commit comments

Comments
 (0)