Login  Register

iceberg: merging branches just at the git level without changing code in the image

Posted by Andrei Chis on Feb 04, 2019; 5:18pm
URL: https://forum.world.st/iceberg-merging-branches-just-at-the-git-level-without-changing-code-in-the-image-tp5094770.html

Hi,

Currently in Iceberg to merge a branch into another, we need to checkout the branch into which we want to merge and then do the merge.
Checking out a branch also updates the code in the image, which when needing to perform automatic releases on a branch can cause issues.

Is there already a way in Iceberg to switch to a branch (for example `release`) and then merge another branch (for example `master`) into it without updating any code in the image?
The use-case is that the user is on the `master` branch and needs to merge `master` into `release` without changing any code in the image.

I found LGitRepository>>#merge:, but it seems not to be used anywhere in the image.

Another way would be to implement something like the method below. This:
  - calculates what changes need to be merged
  - always takes what is on the left branch (in this case what is on master overrides what is on release)
  - does not call loadChangesInWorkingCopy: to update the working copy as the code is already in the image
  - refreshes the dirty packages in case there are changes between what is on the image and what is on disk

```
IceMerge>>#executeWithAcceptingLeftOnConflictAndWithoutImageUpdate
| commitToAdvance |
mergeCommit validateCanMerge.
self isAlreadyMerged ifTrue: [ ^ self ].

self calculateChanges.
self conflictsDo: [ :operation |
operation selectLeft.
].
commitToAdvance := self updateHead.
        "Do not update the working copy"
"repository workingCopy loadChangesInWorkingCopy: self changesToWorkingCopyTree."
repository workingCopy refreshDirtyPackages.
^ commitToAdvance
```

Could something like the above solution work? Or are there other issues to take into account?

Cheers,
Andrei