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

allow to merge forks #63

Merged
merged 31 commits into from
Nov 18, 2023
Merged

allow to merge forks #63

merged 31 commits into from
Nov 18, 2023

Conversation

amtoine
Copy link
Owner

@amtoine amtoine commented Nov 4, 2023

description

  • add a new nu-git-manager git repo module with
    • get-root-commit to get the first commit of a local repo
    • is-grafted to check for grafted repos
    • the two commands are tested in tests root-commit and tests detect-grafting respectively
    • in order for them to work, Git is now configured in the CI
  • add a throw-warning command
  • store record<path: path, grafted: bool, root: string> in the cache to detect forks
    • update the tests and the cache updates in gm
  • detect forks when cloning a new repo and give a warning without changing anything

what it looks like to clone repos now

  • cloning a grafted repo, i.e. which won't be used for fork detection
> tk run --clean { gm clone https://github.com/amtoine/nushell --depth 1 }
Cloning into '/tmp/foo/github.com/amtoine/nushell'...
...
Warning:    cloning_grafted_repository
| this repo is grafted, cannot detect forks
updating cache... done
  • cloning a first fork of Nushell
> tk run --clean { gm clone https://github.com/fdncred/nushell }
Cloning into '/tmp/foo/github.com/fdncred/nushell'...
...
updating cache... done
  • cloning a second fork of Nushell: one fork detected
> tk run { gm clone https://github.com/kubouch/nushell }
Cloning into '/tmp/foo/github.com/kubouch/nushell'...
...
Warning:    cloning_fork
| this repo is a fork of 1 other repo because they share the same root commit: 8f3b273337b53bd86d5594d5edc9d4ad7242bd4c
| - github.com/fdncred/nushell
updating cache... done
  • cloning a last fork of Nushell: two forks detected
> tk run { gm clone https://github.com/nushell/nushell }
Cloning into '/tmp/foo/github.com/nushell/nushell'...
...
Warning:    cloning_fork
| this repo is a fork of 2 other repos because they share the same root commit: 8f3b273337b53bd86d5594d5edc9d4ad7242bd4c
| - github.com/fdncred/nushell
| - github.com/kubouch/nushell
updating cache... done

Note
the real rendering:
2023-11-06-121223_1920x1080_scrot

TODO

  • add root commit and graf status to the cache
  • give a warning when cloning a non-grafted fork
  • add a command to merge forks together
  • do the TODOs and FIXMEs in the changes

Sorry, something went wrong.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@amtoine amtoine added enhancement New feature or request core Related to the main `nu-git-manager` module labels Nov 4, 2023
amtoine added a commit that referenced this pull request Nov 4, 2023
as per title, for consistency with the rest of `nu-git-manager`.

Co-authored-by: tests-ci <[email protected]> (yeah i messed up my local config with the CI of #63)
a "repo record" contains
- `$.path: path`: the path to the repo
- `$.grafted: bool`: whether the repo has been grafted or not
- `$.root: string`: the hash of the root commit of the repo
@melMass
Copy link
Collaborator

melMass commented Nov 6, 2023

Nice, I wouldn't expose "get-root-commit" (or maybe in sugar) and in the cache I would change "root" to "hash"

@amtoine
Copy link
Owner Author

amtoine commented Nov 6, 2023

Nice, I wouldn't expose "get-root-commit" (or maybe in sugar)

get-root-commit is required in mod.nu so we need to export it 🤔

in the cache I would change "root" to "hash"

i've renamed it to root_hash in 14a2f69, to keep the idea that it's the hash of the root commit, it's not the hash of the files for instance 😋

@amtoine amtoine marked this pull request as ready for review November 9, 2023 17:51
@amtoine
Copy link
Owner Author

amtoine commented Nov 9, 2023

that Windows CI was not that bad 😌

@melMass melMass merged commit 137dbfa into main Nov 18, 2023
@amtoine amtoine deleted the merge-forks branch November 18, 2023 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to the main `nu-git-manager` module enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

detect when cloning a fork of a local repo
2 participants