diff --git a/Iceberg-Tests.package/IceGitMergeTest.class/instance/testMergeOfInnessaryMergeCommit.st b/Iceberg-Tests.package/IceGitMergeTest.class/instance/testMergeOfInnessaryMergeCommit.st new file mode 100644 index 0000000000..6194071a4e --- /dev/null +++ b/Iceberg-Tests.package/IceGitMergeTest.class/instance/testMergeOfInnessaryMergeCommit.st @@ -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. diff --git a/Iceberg-Tests.package/IceGitMergeTest.class/instance/testMergeWithEmptyIncomingCommitCreatesMergeCommit.st b/Iceberg-Tests.package/IceGitMergeTest.class/instance/testMergeWithEmptyIncomingCommitCreatesMergeCommit.st new file mode 100644 index 0000000000..f367aa15e6 --- /dev/null +++ b/Iceberg-Tests.package/IceGitMergeTest.class/instance/testMergeWithEmptyIncomingCommitCreatesMergeCommit.st @@ -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 \ No newline at end of file diff --git a/Iceberg-Tests.package/IceGitMergeTest.class/instance/testMergeWithMissingProjectFile.st b/Iceberg-Tests.package/IceGitMergeTest.class/instance/testMergeWithMissingProjectFile.st new file mode 100644 index 0000000000..cb8972e20f --- /dev/null +++ b/Iceberg-Tests.package/IceGitMergeTest.class/instance/testMergeWithMissingProjectFile.st @@ -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 \ No newline at end of file diff --git a/Iceberg.package/IceMerge.class/instance/updateHead.st b/Iceberg.package/IceMerge.class/instance/updateHead.st index 4a730aff75..c26a72f09e 100644 --- a/Iceberg.package/IceMerge.class/instance/updateHead.st +++ b/Iceberg.package/IceMerge.class/instance/updateHead.st @@ -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 \ No newline at end of file diff --git a/Iceberg.package/IceWorkingCopy.class/instance/commitChanges.withMessage..st b/Iceberg.package/IceWorkingCopy.class/instance/commitChanges.withMessage..st index 6d280f8c4a..6b1e33eb60 100644 --- a/Iceberg.package/IceWorkingCopy.class/instance/commitChanges.withMessage..st +++ b/Iceberg.package/IceWorkingCopy.class/instance/commitChanges.withMessage..st @@ -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 \ No newline at end of file + ^ self commitChanges: aDiff withMessage: message force: false \ No newline at end of file diff --git a/Iceberg.package/IceWorkingCopy.class/instance/commitChanges.withMessage.force..st b/Iceberg.package/IceWorkingCopy.class/instance/commitChanges.withMessage.force..st new file mode 100644 index 0000000000..b61f40e285 --- /dev/null +++ b/Iceberg.package/IceWorkingCopy.class/instance/commitChanges.withMessage.force..st @@ -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 \ No newline at end of file diff --git a/README.md b/README.md index 7c9297da16..3acb5ba44e 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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.