Gitify icon indicating copy to clipboard operation
Gitify copied to clipboard

How to Merge using Gitfy

Open adamwintle opened this issue 10 years ago • 7 comments

Sorry if this is covered elsewhere, I couldn't find anything in other issues or the Wiki.

Can Gitify merge just as Git does?

We have a branch of the project, where Developer A adds some elements which changes the DB, creating some new IDs in the table. When we come to the point of merging the branches, first running Gitify extract on Developer A's machine, and then on Developer B's machine we run git pull, Gitify Build and get Gitify errors due to already existing IDs in the database.

What we realised is Developer B had also created some new IDs in the table which happened to use the same IDs from Developer A's work, and Gitify didn't know if they should be merged or increment the IDs.

Essentially this was a Gitify conflict.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

adamwintle avatar Mar 12 '15 17:03 adamwintle

The majority of simple conflicts should be solve-able by merging with git. Basically Gitify extract, git commit, git pull (which should do the merge then) and finally Gitify build.

The tricky thing is indeed when you get IDs mixed up from different branches. Part of the problem should be smoothed out because of the ability to specify a different primary (for elements, that means it tries to read/build elements based on their name instead of ID) which makes it easier to resolve. But as it tries to force the same ID, resolving those conflicts are still manual - i.e. if you encounter duplicate IDs, you need to update the file with a new ID (or none at all) and do another Gitify build.

I would like to add clever ID handling to Gitify to identify duplicates in the build process, so it can be resolved before it tries to inject something with an ID that already exists. What I have in mind is populating an array with the used IDs, and checking that on every pass. If it finds an object with an ID that already exists, skip it until the end of processing that particular object, and then insert it with the next auto incremented ID. Of course this needs to inform the user, and also update the build files with the new ID so it doesn't happen all the time, and that the new ID is consistent. It's up to the user then to commit and push the changes, but at least the complex bit is automatically resolved.

Mark-H avatar Mar 12 '15 21:03 Mark-H

In the meantime we are using a quick and dirty hack: Developer B bumps up autoincrements on the affected modx tables to a high number, unlinely to be reached (eg. 1000).

mjsarfatti avatar May 01 '15 19:05 mjsarfatti

ID conflict resolution is on its way - there's a separate branch with the work in progress. Op 1 mei 2015 9:43 PM schreef "Manuele J Sarfatti" <[email protected]

:

In the meantime we are using a quick and dirty hack: Developer B bumps up autoincrements on the affected modx tables to a high number, unlinely to be reached (eg. 1000).

— Reply to this email directly or view it on GitHub https://github.com/modmore/Gitify/issues/69#issuecomment-98216616.

Mark-H avatar May 01 '15 19:05 Mark-H

Another scenario where duplicates are an issue is when one user moves and renames a resource in between commits. When building on another install Gitify sees this as a new resource and tries to create it, causing an ID conflict, even though it's the same page, just in a different location. No idea how you'd get around this one (sorry!). --force overcomes it, but then you lose any changes you'd want to merge

studiorepublic avatar May 13 '15 10:05 studiorepublic

The new ID conflict resolution should automatically resolve that scenario on a regular build @studiorepublic. :) The #86 pull request (feature-id-conflict-resolution branch) should already work, I just need to add it to resources as well (it currently runs on everything except resources).

Mark-H avatar May 13 '15 10:05 Mark-H

Should have known you'd have it in hand, Mark! Nice one

studiorepublic avatar May 13 '15 10:05 studiorepublic

PR #86 has been merged, v0.9 released, this now automatically increments the ID and re-extracts that partition, like this:

screen shot 2015-05-15 at 12 07 52

To handle situations where a resource is moved, or an object renamed, I also threw in orphan handling. Basically anything that is not in the files will be automatically removed. Because cleaning up orphans is handled prior to resolving conflicts, they're now added as expected without creating actual duplicates with different IDs:

screen shot 2015-05-15 at 11 34 04

Mark-H avatar May 15 '15 10:05 Mark-H