Lucas_Werkmeister_WMDE claimed this task.
Lucas_Werkmeister_WMDE moved this task from Backlog to Doing on the Wikibase 
Extension Decoupling and Registration (Sprint 3) board.
Lucas_Werkmeister_WMDE added a comment.


  I’ve been playing with `git subtree` and found something that works. 
Basically, it’s a bunch of `git subtree split`s (or `push`es), wired together 
using `git replace` – two `git replace`s are necessary to connect the history 
past the changes → Changes directory rename 
<https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/284190>, and 
one `git replace` connects the those old histories to the new history where in 
Wikibase.git the library is now under `lib/packages/changes/`. `git replace` 
refs are not pushed or pulled by default, but can be transferred explicitly, so 
we would add something to the README advising users to run `git fetch origin 
'refs/replace/*:refs/replace/*'` if they want nice Git history (compare 
ceylon.formatter instructions 
<https://github.com/eclipse/ceylon.formatter/#restoring-pre-133-history>).
  
  1. anywhere: `git init /tmp/changes` (git subtree push does not initialize 
the target repo if it doesn’t exist yet, but only tells you this //after// it 
went through all the git history work (which takes a few minutes), which is 
irritating)
  2. in Wikibase: `git subtree push -P lib/includes/Changes/ /tmp/changes/ main`
  3. in Wikibase: `mkdir lib/includes/changes/` (otherwise, `git subtree push 
-P lib/includes/changes/` will refuse to work)
  4. in Wikibase: `git subtree push -P lib/includes/changes/ /tmp/changes/ 
lcase`
  5. in changes: `GIT_EDITOR='sed -i "/^tree/ a parent $(git rev-parse lcase)"' 
git replace --edit de3d9cd700` – de3d9cd700 is the root commit of the initially 
extracted history, where `lib/includes/changes/` became 
`lib/includes/Changes/`; “edit” it to add the last commit of the second 
extracted history, for `lib/includes/changes/`, as its parent
  6. in Wikibase: `git subtree push -P lib/tests/phpunit/Changes/ /tmp/changes 
tests`
  7. in Wikibase: `mkdir lib/tests/phpunit/changes/`
  8. in Wikibase: `git subtree push -P lib/tests/phpunit/changes/ /tmp/changes 
tests-lcase`
  9. in changes: `GIT_EDITOR='sed -i "/^tree/ a parent $(git rev-parse 
tests-lcase)"' git replace --edit 2fdc9baef4`
  10. in changes: `git checkout -b merged "$(git commit-tree "$(printf '040000 
tree %s\t%s\n' "$(git rev-parse main^{tree})" src "$(git rev-parse 
tests^{tree})" tests | git mktree)" -p main -p tests -m 'Merge src and tests 
histories')"` – create a new tree which mounts the `main and `tests` branches 
as `src/` and `tests/` directories; create a new commit from that tree; check 
that commit out as a new branch
  11. in Wikibase: `mkdir -p lib/packages/changes/ && git mv 
lib/includes/Changes/ lib/packages/changes/src/ && git mv 
lib/tests/phpunit/Changes/ lib/packages/changes/tests/ && git commit -m 'Move 
Changes files'`
  12. in Wikibase: `git subtree push -P lib/packages/changes/ /tmp/changes/ 
moved`
  13. in changes: `git replace moved merged`
  
  And now, any further commits made that affect `lib/packages/changes/` (I 
tested with an “Add README”) can be pushed using `git subtree push -P 
lib/packages/changes/ /tmp/changes/ moved`, and the history will do the right 
thing.
  
  That said, this isn’t a very nice history – because `src/` and `tests/` were 
exported separately, there are two copies of most commits, one touching `src/` 
and the other touching `tests/`. I’ll see if I can find a solution for that – 
maybe it can be done using `git filter-branch` instead of `git subtree split`, 
“filtering” the working tree by removing all directories except the few that we 
want to keep. (Doing this via the real `git filter-branch` promises to be 
extremely slow, because it would actually check out the full working tree each 
time and then shell out to `/bin/rm` to remove it again, but I remember hearing 
about a utility that should be able to do it faster.)

TASK DETAIL
  https://phabricator.wikimedia.org/T258395

WORKBOARD
  https://phabricator.wikimedia.org/project/board/4875/

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Lucas_Werkmeister_WMDE
Cc: Lucas_Werkmeister_WMDE, Addshore, Aklapper, Tarrow, Akuckartz, 
darthmon_wmde, Nandana, Lahi, Gq86, GoranSMilovanovic, QZanden, LawExplorer, 
_jensen, rosalieper, Scott_WUaS, Wikidata-bugs, aude, Lydia_Pintscher, Mbch331
_______________________________________________
Wikidata-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs

Reply via email to