Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,40 @@ PharoCompatibilityP12SurfacePharo13Test >> testInstallPharo12SurfacePreservesMis
(Smalltalk includesKey: #RBPushDownInstanceVariableRefactoring)
]

{ #category : 'tests' }
PharoCompatibilityP12SurfacePharo13Test >> testRunGitCommitUsesRepositoryGitIdentity [

| author location |
location := FileLocator temp
/ ('PharoCompatibilityGitIdentity-' , UUID new asString).
location ensureCreateDirectory.
[
PharoCompatibility
runGitCommandWithArguments: #( 'init' )
in: location.
PharoCompatibility
runGitCommandWithArguments: #( 'config' 'user.name' 'Configured Author' )
in: location.
PharoCompatibility
runGitCommandWithArguments: #( 'config' 'user.email' 'configured@example.test' )
in: location.
(location / 'tracked.txt') writeStreamDo: [ :stream |
stream nextPutAll: 'tracked' ].
PharoCompatibility
runGitCommandWithArguments: #( 'add' '--' 'tracked.txt' )
in: location.
PharoCompatibility
runGitCommitWithMessage: 'Use configured identity'
in: location.
author := PharoCompatibility
gitOutputWithArguments: #( 'log' '-1' '--format=%an <%ae>' )
in: location.
self
assert: author
equals: 'Configured Author <configured@example.test>' ] ensure: [
location ensureDeleteAll ]
]

{ #category : 'tests' }
PharoCompatibilityP12SurfacePharo13Test >> testWithNonInteractiveAuthorUsesShimWhenNoAuthorIsConfigured [

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,38 +39,28 @@ PharoCompatibility class >> icebergCommandLineCommitModifiedFilePaths: modifiedF
]

{ #category : '*PharoCompatibility-Pharo12Surface-Pharo13' }
PharoCompatibility class >> icebergCommitAuthorName [
PharoCompatibility class >> icebergCommitAuthorNameForRepository: repository [

| fullName |
fullName := PharoCompatibilityAuthor fullNamePerSe.
(fullName notNil and: [ fullName notEmpty ]) ifTrue: [ ^ fullName ].
^ 'PharoCompatibility'
^ self
gitOutputWithArguments: #( 'log' '-1' '--format=%an' )
in: repository location
]

{ #category : '*PharoCompatibility-Pharo12Surface-Pharo13' }
PharoCompatibility class >> icebergCommitForRepository: repository message: message parentCommits: parentCommits [

| commitId |
commitId := self
gitOutputWithArguments: #( 'rev-parse' 'HEAD' )
in: repository location.
gitOutputWithArguments: #( 'rev-parse' 'HEAD' )
in: repository location.
^ IceGitCommit new
id: commitId;
author: self icebergCommitAuthorName;
datetime: DateAndTime now;
ancestorIds: (parentCommits collect: [ :each | each id ]);
comment: message;
repository: repository;
yourself
]

{ #category : '*PharoCompatibility-Pharo12Surface-Pharo13' }
PharoCompatibility class >> icebergCommitSignatureForRepositoryHandle: repositoryHandle [

^ LGitSignature
name: self icebergCommitAuthorName
email: 'pharo-compatibility@example.invalid'
when: DateAndTime now
id: commitId;
author: (self icebergCommitAuthorNameForRepository: repository);
datetime: DateAndTime now;
ancestorIds: (parentCommits collect: [ :each | each id ]);
comment: message;
repository: repository;
yourself
]

{ #category : '*PharoCompatibility-Pharo12Surface-Pharo13' }
Expand Down Expand Up @@ -106,32 +96,13 @@ PharoCompatibility class >> runGitCommandWithArguments: argumentStrings in: repo
{ #category : '*PharoCompatibility-Pharo12Surface-Pharo13' }
PharoCompatibility class >> runGitCommitWithMessage: message in: repositoryLocation [

| authorName command status |
authorName := self icebergCommitAuthorName.
command := String streamContents: [ :stream |
stream
nextPutAll: 'GIT_AUTHOR_NAME=';
nextPutAll: (self posixShellQuote: authorName);
space;
nextPutAll: 'GIT_AUTHOR_EMAIL=';
nextPutAll:
(self posixShellQuote:
'pharo-compatibility@example.invalid');
space;
nextPutAll: 'GIT_COMMITTER_NAME=';
nextPutAll: (self posixShellQuote: authorName);
space;
nextPutAll: 'GIT_COMMITTER_EMAIL=';
nextPutAll:
(self posixShellQuote:
'pharo-compatibility@example.invalid');
space;
nextPutAll: (self
gitCommandWithArguments: {
'commit'.
'-m'.
message withUnixLineEndings }
in: repositoryLocation) ].
| command status |
command := self
gitCommandWithArguments: {
'commit'.
'-m'.
message withUnixLineEndings }
in: repositoryLocation.
status := LibC runCommand: command.
status = 0 ifFalse: [
Error signal: 'Git commit failed with status ' , status asString ]
Expand Down
Loading