Skip to content

Commit

Permalink
WIP: use pending changes objects
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusDoe committed Oct 11, 2024
1 parent 4a2db0e commit d0f9a98
Show file tree
Hide file tree
Showing 62 changed files with 196 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public-accessing
firstParent
^ self parents ifNotEmpty: #first ifEmpty: [nil]
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"basicParents" : "MaxLeske 2/26/2012 11:29",
"committer" : "MaxLeske 2/28/2012 11:12",
"committer:" : "MaxLeske 5/26/2010 19:51",
"firstParent" : "mad 10/8/2024 22:06",
"hexHashAtPath:" : "mad 10/1/2024 22:54",
"initialize" : "MaxLeske 2/27/2012 21:47",
"isAncestorOf:" : "jr 5/23/2017 11:29",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
actions
actionChooseNewRepositoryLocationForActiveProject
(self activeWorkingCopyIfNilInformAnd: [^ self]) requestAndMoveToNewRepositoryLocation.
self everythingChanged.
self activeWorkingCopyAction: [:workingCopy |
workingCopy requestAndMoveToNewRepositoryLocation.
self everythingChanged].
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
actions
actionCommit
self activeWorkingCopyIfNilInformAnd: [^ self].
self openDialogToCommitImageWithInitialMessage: ''.
self activeWorkingCopyAction: #openDialogToCommitImage.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
actions
actionCompareCommitToImage: aCommit
self activeWorkingCopyIfNilInformAnd: [^ self].
self openDialogToShowChangeSetsFromImageTo: aCommit.
self activeWorkingCopyAction: [:workingCopy |
workingCopy openDialogToShowChangeSetsFromImageTo: aCommit].
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
actions
actionCompareCommitToParent: aCommit
| parent |
self activeWorkingCopyIfNilInformAnd: [^ self].
parent := aCommit parents ifNotEmpty: #first ifEmpty: [nil].
self openDialogToShowChangeSetsFromCommit: parent to: aCommit.
self activeWorkingCopyAction: [:workingCopy |
workingCopy openDialogToCompareCommitToParent: aCommit]
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
actions
actionCreateBranchAtCommit: aCommit
^ self actionCreateBranchAtCommit: aCommit fromRef: nil
self activeWorkingCopyAction: [:workingCopy |
workingCopy createBranchAtCommit: aCommit].
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
actions
actionCreateBranchAtRef: aString
| commit |
commit := (self commitReferencedBy: aString to: 'create a branch') ifNil: [^ nil].
^ self actionCreateBranchAtCommit: commit fromRef: aString
self activeWorkingCopyAction: [:workingCopy |
workingCopy createBranchAtRef: aString].
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ actionMaterializeCherryPick: aCommit
onConflictOpenDialogToMaterializeChangeSets:
(self activeWorkingCopy
changeSetsToMergeCommitIntoHead: aCommit
withBase: (self parentForPick: aCommit))
withBase: aCommit firstParent)
windowTitle: ('Resolve conflicts to edit {1}' format: {aCommit showOneLine})
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
actions
activeWorkingCopyAction: aBlock
self activeWorkingCopy ifNil: [
self inform: 'Please select a project first.'.
^ self].
aBlock value: self activeWorkingCopy.
15 changes: 8 additions & 7 deletions src/GitS-Core.package/GSBrowser.class/methodProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
"unload" : "mad 9/26/2023 15:50",
"unregisterFromWorldMenu" : "mad 9/19/2023 13:45" },
"instance" : {
"actionChooseNewRepositoryLocationForActiveProject" : "mad 12/22/2023 18:15",
"actionChooseNewRepositoryLocationForActiveProject" : "mad 10/8/2024 22:03",
"actionCloneProject" : "mad 10/9/2024 16:01",
"actionCommit" : "mad 4/5/2024 15:21",
"actionCompareCommitToImage:" : "mad 4/5/2024 19:00",
"actionCompareCommitToParent:" : "mad 4/5/2024 19:01",
"actionCommit" : "mad 10/8/2024 22:03",
"actionCompareCommitToImage:" : "mad 10/8/2024 22:04",
"actionCompareCommitToParent:" : "mad 10/8/2024 22:14",
"actionCreateBranchAtActiveCommit" : "mad 4/5/2024 19:08",
"actionCreateBranchAtCommit:" : "mad 4/5/2024 19:01",
"actionCreateBranchAtCommit:" : "mad 10/8/2024 22:40",
"actionCreateBranchAtCommitAndSwitchToIt:" : "mad 4/5/2024 19:09",
"actionCreateBranchAtRef:" : "mad 4/5/2024 19:45",
"actionCreateBranchAtRef:" : "mad 10/8/2024 22:39",
"actionCreateBranchAtRefAndSwitchToIt:" : "mad 4/5/2024 19:19",
"actionCreateGitBranchAtCommit:" : "mad 4/5/2024 19:24",
"actionCreateGitBranchAtCommit:fromRef:" : "mad 4/10/2024 19:17",
Expand All @@ -27,7 +27,7 @@
"actionFixup:keepCurrentMessage:editMessage:" : "mad 4/5/2024 15:12",
"actionForcePush" : "mad 5/18/2024 11:33",
"actionForcePush:" : "mad 5/18/2024 11:32",
"actionMaterializeCherryPick:" : "mad 10/7/2024 17:35",
"actionMaterializeCherryPick:" : "mad 10/8/2024 22:06",
"actionMaterializeCommit:" : "mad 4/5/2024 19:30",
"actionMergeCommit:" : "mad 4/5/2024 19:31",
"actionMergeRef:" : "mad 4/5/2024 19:40",
Expand Down Expand Up @@ -64,6 +64,7 @@
"activeRefTreeMember:" : "mad 10/10/2024 01:00",
"activeWorkingCopy" : "mad 9/19/2023 12:38",
"activeWorkingCopy:" : "mad 4/10/2024 19:17",
"activeWorkingCopyAction:" : "mad 10/8/2024 22:04",
"activeWorkingCopyIfNilInformAnd:" : "mad 4/5/2024 19:05",
"addMappersProjectListMenu:" : "mad 10/9/2024 16:01",
"basicActiveCommit:" : "mad 5/15/2024 21:42",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
refs
head
basicHeadRef
^ self unitOfWork ref: self headRefName
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
refs
branches
branchName: aString
^ self branchesBaseName, aString
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
refs
branches
branchesBaseName
^ self refsBaseName, 'heads/'
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
upstream
checkSetUpstreamForCreatedBranch: aString to: anotherString
(self isRemoteRef: anotherString) ifFalse: [^ self].
(self confirm:
('You created a branch {1} from the remote-tracking branch {2}. ',
'Do you want to set the upstream branch of {1} to {2}?'
format: ({aString printString. anotherString printString} collect: [:each | GitReference shortName: each])))
ifFalse: [^ self].
self
setUpstreamRemoteNameAndRef: (self splitRemoteRef: anotherString)
for: aString.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
git-operations
cherryPick: aCommit
^ (self pendingChangeSetsForPick: aCommit)
prefixWindowTitle: 'Cherry-pick ';
initialMessage: aCommit message;
commit
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cloneFrom: aStringOrUrl
target := self unitOfWork objectReferenced: self headRefBasename.
(gitHead isSymbolic and: [self isGitBranchRef: gitHead targetRef]) ifTrue: [ | branchName branch |
branchName := gitHead targetRef allButFirst: self gitBranchesBaseName size.
branch := self createBranchNamed: branchName at: target.
branch := self createBranchNamed: branchName atCommit: target.
self setUpstreamRemoteName: self unitOfWork remoteNames first andRef: branchName for: branch.
target := branch].
self updateSymbolicHeadTo: target.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
refs
commitReferencedBy: aString to: anotherString
| object |
object := self unitOfWork objectReferenced: aString.
(object isKindOf: GitCommit) ifTrue: [^ object].
self inform: ('Cannot {1} at {2}, because it does not refer to a commit'
format: {anotherString. aString printString}).
^ nil
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dialog
compareTitleFrom: anObject to: anotherObject
^ 'Show changes from {1} to {2}' format: {self displayName: anObject. self displayName: anotherObject}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
branches
createBranchAtCommit: aCommit
^ self createBranchAtCommit: aCommit fromRef: nil
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
branches
createBranchAtCommit: aCommit fromRef: aStringOrNil
| name branch |
name := self requestBranchNameFor: 'a branch' at: aCommit fromRef: aStringOrNil.
name isEmptyOrNil ifTrue: [^ nil].
branch := self createBranchNamed: name atCommit: aCommit.
aStringOrNil ifNotNil: [self checkSetUpstreamForCreatedBranch: branch to: aStringOrNil].
^ branch
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
branches
createBranchAtRef: aString
| commit |
commit := (self commitReferencedBy: aString to: 'create a branch') ifNil: [^ nil].
^ self createBranchAtCommit: commit fromRef: aString
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
refs
createBranchNamed: aString at: aCommit
branches
createBranchNamed: aString atCommit: aCommit
| refName target |
refName := self branchName: aString.
(self checkRefExists: refName displayName: aString) ifTrue: [^ nil].
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
refs
head
currentHeadTarget
^ self headRef target
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
refs
head
currentSymbolicHeadTarget
^ self headRef isSymbolic
ifTrue: [self currentHeadTarget]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dialog
displayName: anObject
anObject = #image ifTrue: [^ 'the image'].
(anObject isKindOf: GitCommit) ifTrue: [^ anObject showOneLine].
anObject ifNil: [^ '[no commit]'].
(anObject isKindOf: String) ifTrue: [^ GitReference shortName: anObject].
self error: 'unknown object supplied to displayName:'.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
refs
git-branches
gitBranchName: aString
^ self gitBranchesBaseName, aString
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
refs
git-branches
gitBranchesBaseName
^ 'refs/heads/'
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
refs
head
headCommit
^ self unitOfWork objectReferenced: self headRefName
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
refs
head
headCommitHash
^ self unitOfWork resolveRef: self headRefName
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
refs
head
headCommitIfNilInformAnd: aBlock
^ self headCommit ifNil: [
self inform: 'Please create a commit first.'.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
refs
head
headFSCommit
^ self fsCommitFrom: (self headCommit ifNil: [^ nil])
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
refs
head
headFSCommitIfNilInformAnd: aBlock
^ self fsCommitFrom: (self headCommitIfNilInformAnd: [^ aBlock value])
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
refs
head
headRef
^ self basicHeadRef ifNil: [
self unitOfWork
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
refs
head
headRefBasename
^ 'HEAD'
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
refs
head
headRefName
^ self refName: self headRefBasename
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
refs
git-branches
isGitBranchRef: aString
^ aString beginsWith: self gitBranchesBaseName
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
refs
head
isHeadDetached
^ self headRef isSymbolic not
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
refs
head
isReferencedByHead: aString
self unitOfWork followSymbolicRefs: self headRefName do: [:each |
each = aString ifTrue: [^ true]].
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
refs
remotes
isRemoteRef: aString
^ (aString beginsWith: self remoteRefBaseName)
and: [(aString occurrencesOf: $/) >= ((self remoteRefBaseName occurrencesOf: $/) + 1)]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
refs
head
isSomeHead: aString
| refBasename |
refBasename := aString allButFirst: (aString lastIndexOf: $/).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
refs
branches
isSqueakBranchRef: aString
^ aString beginsWith: self branchesBaseName
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dialog
openDialogToCommitImage
^ self openDialogToCommitImageWithInitialMessage: ''
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dialog
openDialogToCommitImageWithInitialMessage: aString
^ self pendingChangeSetsFromHeadCommitToImage
windowTitle: 'Changes to commit';
initialMessage: aString;
alwaysOpenDialog;
commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dialog
openDialogToCompareCommit: aCommit to: anotherCommit
^ (self pendingChangeSetsFromCommit: anotherCommit to: aCommit)
windowTitle: (self compareTitleFrom: aCommit to: anotherCommit);
show
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dialog
openDialogToCompareCommitToImage: aCommit
^ (self pendingChangeSetsFromImageToCommit: aCommit)
windowTitle: (self compareTitleFrom: #image to: aCommit);
show
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dialog
openDialogToCompareCommitToParent: aCommit
^ self openDialogToCompareCommit: aCommit to: aCommit firstParent
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pending-changes
pendingChangeSets: aCollection
^ GSChangesToCommit new
workingCopy: self;
changeSets: aCollection;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pending-changes
pendingChangeSetsForPick: aCommit
^ (self pendingChangeSets:
(self
changeSetsToMergeCommitIntoHead: aCommit
withBase: aCommit firstParent))
windowTitle: aCommit showOneLine;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pending-changes
pendingChangeSetsFromCommit: aCommit toCommit: anotherCommit
^ self pendingChangeSets: (self changeSetsFromCommit: aCommit toCommit: anotherCommit)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pending-changes
pendingChangeSetsFromCommitToImage: aCommit
^ self pendingChangeSets: (self changeSetsFromCommitToImage: aCommit)
Loading

0 comments on commit d0f9a98

Please sign in to comment.