--- tags: v3, ops, contracts, research --- # Preserving Git History in Monorepo Packages **Purpose**: This document is for sharing any findings related to [Issue #45: Research how to preserve git history in a monorepo package](https://github.com/HausDAO/daohaus-rage/issues/45) in our *Invisible Suburbs* Kanban board. Ideally we want to preserve the git history of our Baal contract fork when we add it to our monorepo, but we need to do some research to see if this is possible. ## Why? - We'd like to ideally preserve the git history from the work that the Moloch Mystics did on Baal - Preserve the git history in our fork and then build it out from there - Key question is how necessary this is on the main Baal contract as we'd likely want any of our DAOhaus specific contracts to be included in the monorepo instead ## Considerations (Including Only DAOhaus Contracts) - While we want to preserve original git history we'd want to avoid pushing any of our DAOhaus specific changes upstream to the Moloch Mystics' Baal branches - Another idea proposed by Keating is that we can include only the DAOhaus specific contracts in the `contracts` package in the monorepo instead of including the Baal fork - If we do this, we'd only care about the git history of the work that we're specifically doing to the contracts directly impacting our work such as our modified Summoner ## Preserving Git History Notes - [This article](https://medium.com/lgtm/migrating-to-the-monorepo-582106142654) seems to describe a similar usecase as ours and has a pretty thorough walkthrough. The gist: - We'd make sure that our Baal fork is set up as its own remote - Fetch code from the remote - Read the Baal fork commits with `git read-tree --prefix=/packages/contracts --u baalfork/master` - *We'd want to test and doublecheck this* and be sure to grab from the branch we want - Commit changes, rebase, and make PR to add to our monorepo master ## Git Submodules Notes - Link between 2 repositories - Contracts package can reference our Baal fork that is inside another repository - This looks like it would work but may not be the ideal approach -- some folks mention that this can be cumbersome and shifted to monorepo structures instead after wrangling git submodules structures ## Resources and References Found - https://medium.com/lgtm/migrating-to-the-monorepo-582106142654 - This seems to be a pretty thorough and similar situation to what we'd want if we decide to bring in the Baal fork and keep the git history - https://github.com/shopsys/monorepo-tools - This tool was mentioned in a few articles - https://git-scm.com/book/en/v2/Git-Tools-Submodules - https://www.jannikbuschke.de/blog/git-submodules/ - https://www.adaltas.com/en/2021/05/21/js-monorepos-merging-git-repositories/ ## Next Steps - We may want to experiment with the approach outlined in the *Preserving Git History Notes* section if we want to move our Baal fork into the monorepo. I think that we should consider if we need/want to do this and see if we want to start with what Keating mentioned, which is potentially focusing only on including the contracts that we are modifying that are directly related to v3 and then we can link to/integrate Baal in other ways.