Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite git history #31562

Merged
merged 36 commits into from
Jul 9, 2024
Merged

Rewrite git history #31562

merged 36 commits into from
Jul 9, 2024

Conversation

andiradulescu
Copy link
Contributor

@andiradulescu andiradulescu commented Feb 23, 2024

This tackles #28840 and is a continuation of #30824.

This PR addresses master:

  • prevent new large files stricter file size limits #30839
  • move old objects, binary objects and big text files to LFS https://github.com/commaai/openpilot/pull/31562/files#diff-35f170270f2172a621c54f4e4ceb7f9675b74a90eb359b376202f6a80c819aa2R231
  • prepend the devel release history - from v0.7.1
  • tags - all tagged off master
  • one liner for external contributors to create a new branch to open a new PR on the new history (git cherry-pick A^..B where A is the first commit and B is the last commit, from their old PR)
  • validation of the new history
  • archive of old history - if over 2GB, git push fails
  • commits will contain their old commit id, Former-commit-id: b38c580
  • rebase all branches on upstream - except ones that can't be done automatically and prebuilt branches
  • deal with PRs - PRs stay open if the rest of the branches are also rewritten
  • test the script at least a couple of times

Continued in #32955

@jnewb1
Copy link
Contributor

jnewb1 commented Feb 23, 2024

20.83 MiB ❤️

image

@andiradulescu
Copy link
Contributor Author

andiradulescu commented Feb 23, 2024

Good eye @jnewb1 - yes, it's very small ❤️

GitLab LFS is 6.3 GiB though, but that's not an issue. Since when you cloned openpilot-tiny, only 250MB of LFS files are downloaded.

I uploaded the LFS on GitLab (as you do).

One reason I keep the last lines in the script commented, is that it spams LFS and will upload LFS files everytime the reference ids of the lfs files change.

So, don't run the script until I finish it.

scripts/bfg.sh Outdated
# /tmp/git-filter-repo --invert-paths --path external/ --path phonelibs/

# check the git-filter-repo analysis again - can be found in the repo root/filter-repo/analysis
/tmp/git-filter-repo --force --analyze
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm most interested in knowing the top remaining files and their sizes. does this have it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now you can find the latest analysis in this folder https://github.com/andiradulescu/openpilot/tree/bfg/scripts/analysis - I will try to import more files to lfs and I will keep updating the folder.

fyi external and phonelibs folder were initially deleted completely at the time of this comment #31562 (comment) - so still need to either add both folders to lfs or just add the big files inside them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

analysis of the current commaai/openpilot repo can be found here https://github.com/andiradulescu/openpilot/tree/bfg/scripts/analysis-before

scripts/bfg.sh Outdated Show resolved Hide resolved
scripts/delete.py Outdated Show resolved Hide resolved
@adeebshihadeh adeebshihadeh marked this pull request as draft February 23, 2024 21:05
@andiradulescu
Copy link
Contributor Author

My strategy (like it or hate it):

  1. push new master as “main” branch (new branch)
  2. put a github action on master on every push (to master) to take the last commit that was pushed to master and cherry pick it on “main”
  3. make “main” the main branch of the github repo
  4. everyone works as they worked before, just that when they start a new feature they should now start from “main”
  5. for some time there will be PRs opened for “main” and PRs open for “master”
  6. we set a deadline for 30 days for everyone to move to “main”
  7. when we reach the deadline we close all opened PRs to “master” and remove the “master” branch (and push it to archive repo)
  8. clean all other branches we don’t need anymore
  9. clean the repo of anything else that might need to be cleaned so that a new clone is 20MB not 3GB

The strategy takes 30 days to apply, but shouldn’t disrupt anyone in the 30 days.

After the 30 days, will be disruptive for users that need to move forcefully on main.

Didn’t do this strategy before. It’s a new idea.

@devtekve
Copy link
Contributor

My strategy (like it or hate it):

  1. push new master as “main” branch (new branch)
  2. put a github action on master on every push (to master) to take the last commit that was pushed to master and cherry pick it on “main”
  3. make “main” the main branch of the github repo
  4. everyone works as they worked before, just that when they start a new feature they should now start from “main”
  5. for some time there will be PRs opened for “main” and PRs open for “master”
  6. we set a deadline for 30 days for everyone to move to “main”
  7. when we reach the deadline we close all opened PRs to “master” and remove the “master” branch (and push it to archive repo)
  8. clean all other branches we don’t need anymore
  9. clean the repo of anything else that might need to be cleaned so that a new clone is 20MB not 3GB

The strategy takes 30 days to apply, but shouldn’t disrupt anyone in the 30 days.

After the 30 days, will be disruptive for users that need to move forcefully on main.

Didn’t do this strategy before. It’s a new idea.

If I can add some input, for the step 6 I’d only apply it to new PRs, otherwise it gives a 30day timeout for existing WIP which might be a bit tight. New PRs after the deadline should be rejected in favor of PRs to main

@adeebshihadeh
Copy link
Contributor

RE: rollout, I'm not interested in dealing with a slow rollout, so we'll do it quickly and put some effort into rebasing PRs automatically for people.

@andiradulescu
Copy link
Contributor Author

Small update here: rebasing master onto v0.7.1 took more than expected until I found the proper hacks. Check handle_conflicts() in my latest commit.

Right now, I'm testing this since rebasing 12040 commits is not that fast.

And during the rebase I get some logs like this:
dropping a4cec444eb3b158176f0650b414090197e7610d4 bump version to 0.8.2 -- patch contents already upstream
and investigating if this is correct or not.

@commaai commaai deleted a comment from github-actions bot Mar 9, 2024
@adeebshihadeh
Copy link
Contributor

Anything I can help with on this? Is there a particular blocker?

@andiradulescu
Copy link
Contributor Author

The current blocker is me. Will try to unblock myself and make more progress today.

Otherwise, you can unlock the bounty. Maybe @devtekve is interested.

@devtekve
Copy link
Contributor

The current blocker is me. Will try to unblock myself and make more progress today.

Otherwise, you can unlock the bounty. Maybe @devtekve is interested.

Thanks ❤️ but not really, if it’s for me don’t unlock it! I was just chiming in. If there’s anything I can help with feel free to ping me tho

@github-actions github-actions bot added the stale label Apr 20, 2024
@andiradulescu andiradulescu marked this pull request as ready for review April 30, 2024 10:44
@github-actions github-actions bot added the stale label May 16, 2024
@adeebshihadeh adeebshihadeh marked this pull request as draft May 22, 2024 00:21
Copy link
Contributor

github-actions bot commented May 28, 2024

Thanks for contributing to openpilot! In order for us to review your PR as quickly as possible, check the following:

  • Convert your PR to a draft unless it's ready to review
  • Read the contributing docs
  • Before marking as "ready for review", ensure:
    • the goal is clearly stated in the description
    • all the tests are passing
    • the change is something we merge
    • include a route or your device' dongle ID if relevant

@commaai commaai deleted a comment from github-actions bot Jun 7, 2024
@andiradulescu
Copy link
Contributor Author

@adeebshihadeh I edited the first comment with some checkboxes - #31562 (comment) - let me know what you think

@maxime-desroches maxime-desroches marked this pull request as ready for review July 9, 2024 05:04
@maxime-desroches
Copy link
Contributor

Merging as is, feel free to open a pr if you need to add something to your script. We still have to wait untill all the cars stuff is out before actually doing the rewrite

@maxime-desroches maxime-desroches merged commit 481e5b2 into commaai:master Jul 9, 2024
14 of 15 checks passed
@andiradulescu
Copy link
Contributor Author

Glad seeing this merged! I’m still running it and changing small things to it, I’ll open a new PR after I stop testing and polishing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants