Skip to content

Commit

Permalink
Merge 512dca8
Browse files Browse the repository at this point in the history
  • Loading branch information
guillep committed Aug 13, 2018
2 parents 1066e84 + 512dca8 commit a39ee7f
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
tests
testMergeOfInnessaryMergeCommit
| c1 c2 c3 c4 i1 fileRef|

"When producing a merge, sometimes Github produces a merge commit that is not necessary.
This merge commit includes two commits that are also included in the chain of ancestors of the head.
Initial state:
(c4) <-- master
|
|
|
v
(c3) <--(i1) <-- incoming
| |
v |
(c2) |
| |
v |
(c1) <----
Expected State:
(merge)-- <-- master
| |
| |
v |
(c4) |
| |
| |
| |
v v
(c3) <--(i1) <-- incoming
| |
v |
(c2) |
| |
v |
(c1) <----
"

c1 := self repository commitWithMessage: 'C1'.

fileRef := self repository location / 'c2.txt'.
fileRef writeStreamDo: [ :stream | stream << 'c2' ].
self repository index addPath: (fileRef relativeTo: self repository location).
c2 := self repository commitWithMessage: 'C2'.

fileRef := self repository location / 'c3.txt'.
fileRef writeStreamDo: [ :stream | stream << 'c3' ].
self repository index addPath: (fileRef relativeTo: self repository location).
c3 := self repository commitWithMessage: 'C3'.

fileRef := self repository location / 'c4.txt'.
fileRef writeStreamDo: [ :stream | stream << 'c4' ].
self repository index addPath: (fileRef relativeTo: self repository location).
c4 := self repository commitWithMessage: 'C4'.

c3 checkout.
self repository checkoutBranch: 'incoming'.

i1 := self repository
commitIndexWithMessage: 'Merge'
andParents: {c3. c1}.

self repository checkoutBranch: 'master'.

i1 merge.

self assert: self repository branch commit ancestors equals: { c4. i1 }.
self assert: self repository branch commit comment equals: 'Merge ' , i1 id.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
tests
testMergeWithEmptyIncomingCommitCreatesMergeCommit
| incomingBranch |

self repository checkoutBranch: 'master'.
self repository workingCopy project: self repository newUnbornProject.
self repository commitWithMessage: 'Remove project file'.

self repository checkoutBranch: 'localBranch'.
self repository workingCopy project: (IceBasicProject onRepository: self repository withSourceDirectory: '').
self repository commitWithMessage: 'commit project file'.
incomingBranch := self repository branch.

self repository checkoutBranch: 'master'.
self repository workingCopy project: (IceBasicProject onRepository: self repository withSourceDirectory: '').
self repository commitWithMessage: 'second commit in master'.

incomingBranch merge.

self assert: self repository workingCopy referenceCommit comment equals: 'Merge ' , incomingBranch commit id
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
tests
testMergeWithMissingProjectFile
| incomingBranch fileRef |

self repository checkoutBranch: 'master'.
self repository commitWithMessage: 'Initial Commit'.

self repository checkoutBranch: 'localBranch'.
self repository workingCopy project: self repository newUnbornProject.
fileRef := self repository location / 'test1.txt'.
fileRef writeStreamDo: [ :stream | stream << 'test1' ].
self repository index addPath: (fileRef relativeTo: self repository location).
self repository commitWithMessage: 'commiting something'.
incomingBranch := self repository branch.

self repository checkoutBranch: 'master'.
self repository workingCopy project: (IceBasicProject onRepository: self repository withSourceDirectory: '').
fileRef := self repository location / 'test2.txt'.
fileRef writeStreamDo: [ :stream | stream << 'test2' ].
self repository index addPath: (fileRef relativeTo: self repository location).
self repository commitWithMessage: 'second commit in master'.

incomingBranch merge.

self assert: self repository workingCopy referenceCommit comment equals: 'Merge ' , incomingBranch commit id
2 changes: 1 addition & 1 deletion Iceberg.package/IceMerge.class/instance/updateHead.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ updateHead
setMergeStateBetweenCommits:
{self leftCommit.
mergeCommit}.
repository workingCopy commitChanges: self withMessage: 'Merge ' , mergeCommit id asString ].
repository workingCopy commitChanges: self withMessage: 'Merge ' , mergeCommit id asString force: true ].
repository branch commit: commitToAdvance
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
API-commits
commitChanges: aDiff withMessage: message
"Creates a commit with the given changes using the comment given as argument.

NOTICE that commits can only be done if the following is true:
- HEAD is a branch
- the working copy reference commit is the same commit as #headCommit"

| newCommit |
self validateCanCommit.
self repository index
updateDiskWorkingCopy: aDiff;
updateIndex: aDiff.

repository index isEmpty ifTrue: [ IceNothingToCommit signal ].

newCommit := self repository
commitIndexWithMessage: message
andParents: (self workingCopyState referenceCommits reject: [ :each | each isNoCommit ]).
^ newCommit
^ self commitChanges: aDiff withMessage: message force: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
as yet unclassified
commitChanges: aDiff withMessage: message force: forcing

"Creates a commit with the given changes using the comment given as argument.
The forcing parameter allows to create an empty commit. This is used by the merge.
NOTICE that commits can only be done if the following is true:
- HEAD is a branch
- the working copy reference commit is the same commit as #headCommit"

| newCommit |
self validateCanCommit.
self repository index
updateDiskWorkingCopy: aDiff;
updateIndex: aDiff.

(forcing not and: [repository index isEmpty])
ifTrue: [ IceNothingToCommit signal ].

newCommit := self repository
commitIndexWithMessage: message
andParents: (self workingCopyState referenceCommits reject: [ :each | each isNoCommit ]).
^ newCommit
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ default (this **will** be the default on Pharo7). The easiest way to get this VM

***Q.** I'm using Iceberg on Windows - whilst trying to clone a repository I get the error "LGit_GIT_ERROR: error authenticating: failed connecting agent".*
**A.** Prompting for credentials currently doesn't work on Windows (we can't use ssh-agent). You need to setup authentication using SSH keys. Something like this:

***Q.** I'm using 2FA on github and when I try to to create a PR from Iceberg, I'm asked a login/passwd. I try to login but it doesn't work.*
**A.** There is no support for 2FA in Iceberg for the moment. Please create a personal Access Tokens to replace your password in order to avoid this problem: https://github.com/settings/tokens

```Smalltalk
IceCredentialsProvider useCustomSsh: true.
IceCredentialsProvider sshCredentials
Expand All @@ -45,6 +41,9 @@ IceCredentialsProvider sshCredentials

(Your key should not have a passphrase)

***Q.** I'm using 2FA on github and when I try to to create a PR from Iceberg, I'm asked a login/passwd. I try to login but it doesn't work.*
**A.** There is no support for 2FA in Iceberg for the moment. Please create a personal Access Tokens to replace your password in order to avoid this problem: https://github.com/settings/tokens

## Installation (for development)
### Prerequisites
- Latest Pharo 6.1+ image.
Expand Down

0 comments on commit a39ee7f

Please sign in to comment.