Skip to content

Commit 3faf8a7

Browse files
authored
Merge pull request #527 from raymond-rebbeck/force-push
Add an option to allow git push --force to be performed in expert mode
2 parents 0d0af5d + dfac202 commit 3faf8a7

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ 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.7.0] - Unreleased
9+
10+
### Added
11+
- Added 'git push --force' in expert mode (#527)
12+
813
## [2.6.0] - 2024-10-07
914

1015
### Added

cls/SourceControl/Git/Extension.cls

Lines changed: 3 additions & 0 deletions
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,

cls/SourceControl/Git/Utils.cls

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Targe
272272
quit $$$OK
273273
} elseif (menuItemName = "Push") {
274274
quit ..Push()
275+
} elseif (menuItemName = "PushForce") {
276+
set Target = "Force pushing is potentially destructive and may overwrite the commit history of the remote branch. Are you sure you want to proceed?"
277+
set Action = 1 // Make sure the user confirms that they want to do this
278+
quit $$$OK
275279
} elseif (menuItemName = "Fetch") {
276280
$$$QuitOnError(..Fetch(.diffFiles))
277281
set pointer = 0
@@ -321,6 +325,11 @@ ClassMethod AfterUserAction(Type As %Integer, Name As %String, InternalName As %
321325
do ..Sync(Msg)
322326
set Reload = 1
323327
}
328+
} elseif (menuItemName = "PushForce") {
329+
if (Answer = 1) {
330+
do ..Push(,1)
331+
set Reload = 1
332+
}
324333
} elseif (menuItemName = "GitWebUI") {
325334
// Always force reload as many things could have possibly changed.
326335
set Reload = 1

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)