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

opam source --dev fetching git repositories without --depth 1 #5888

Merged
merged 3 commits into from
Apr 5, 2024

Conversation

moyodiallo
Copy link
Contributor

@moyodiallo moyodiallo commented Mar 19, 2024

This PR is about to fix #5061. It turns out we doesn't need a flag for fixing the issue, It is agreed during the opam-dev meeting to avoid fetching with --depth 1 for opam source because on the client side it could be confusing, an idea from @kit-ty-kate.

  • Add an option in the backend
  • Add an flag for opam source client
  • opam source is going to be --deph 1 free when fetching source from dev_repo.
  • Add test for opam source command
  • Add test for opam repository command, to be sure the behavior remains unchanged.

@moyodiallo moyodiallo force-pushed the full-fetch branch 2 times, most recently from bcef852 to deca4d4 Compare March 20, 2024 10:44
@moyodiallo moyodiallo marked this pull request as ready for review March 20, 2024 11:22
Copy link
Member

@kit-ty-kate kit-ty-kate left a comment

Choose a reason for hiding this comment

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

LGTM for the code, apart from the few cosmetic changes pointed below.

However I feel like this type of change (especially when dealing with optional arguments) warrants some addition to the testsuite, so that regressions do not happen in the future. Would it be possible to add one? If so DM me and i can help you navigate in the testsuite.

src/repository/opamGit.ml Outdated Show resolved Hide resolved
src/repository/opamGit.ml Outdated Show resolved Hide resolved
src/repository/opamGit.ml Outdated Show resolved Hide resolved
@kit-ty-kate
Copy link
Member

@moyodiallo you seem to have lost all of your changes except the first commit in the rebase somehow. You can get them back from 2469168

@moyodiallo
Copy link
Contributor Author

moyodiallo commented Mar 25, 2024

@moyodiallo you seem to have lost all of your changes except the first commit in the rebase somehow. You can get them back from 2469168

Done, I was reorganizing it a bit. It's done and ready for an ultimate review.

@kit-ty-kate
Copy link
Member

kit-ty-kate commented Mar 27, 2024

* [x]  Add test for `opam repository` command, to be sure the behavior remains unchanged.

This todo from your own PR description doesn't seem to be in the final PR. Is there a missing commit lost somewhere or you chose not to do this in the end?

EDIT: Nevermind I'm seeing it now. Sorry for the noise

Copy link
Collaborator

@rjbou rjbou left a comment

Choose a reason for hiding this comment

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

Thanks for this first PR!
On the idea, and general implementation, it is good.
I've left some comments, most of them concern the "coding style" of this repository.

master_changes.md Outdated Show resolved Hide resolved
src/repository/opamRepositoryBackend.mli Outdated Show resolved Hide resolved
tests/reftests/source.test Outdated Show resolved Hide resolved
@rjbou rjbou changed the title opam source, fetched with deph 1 could be avoided opam source, fetched with --depth 1 could be avoided Apr 2, 2024
if VCS.exists repo_root then
OpamProcess.Job.catch (fun e -> Done (OpamRepositoryBackend.Update_err e))
@@ fun () ->
OpamRepositoryBackend.job_text repo_name "sync"
(VCS.fetch ?cache_dir repo_root repo_url)
(VCS.fetch ?full_fetch ?cache_dir repo_root repo_url)
Copy link
Member

Choose a reason for hiding this comment

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

@rjbou like this?

Suggested change
(VCS.fetch ?full_fetch ?cache_dir repo_root repo_url)
(VCS.fetch ~full_fetch:false ?cache_dir repo_root repo_url)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Linked to this #5888 (comment).

Copy link
Member

Choose a reason for hiding this comment

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

not really. My comment was linked to a discussion during the dev meeting where we wondered if ?full_fetch should be given explicitly or if it should be omitted when applied

Copy link
Collaborator

Choose a reason for hiding this comment

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

@kit-ty-kate did you want to keep full_fetch:false for fetch_repo_update that is used opam opam repo updates ?

Copy link
Member

Choose a reason for hiding this comment

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

I would prefer personally but as you wish

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good for me in that case :) It is a good safeguard regarding current opam repository.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll add it

src/repository/opamVCS.mli Outdated Show resolved Hide resolved
@@ -316,8 +316,13 @@ first --
### git -C ./OPER add repo
### git -C ./OPER add packages/first
### git -C ./OPER commit -qm "third"
### git -C ./OPER commit --allow-empty -m "second empty commit" --quiet
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is no more needed too, as everything is seen in source test

Copy link
Contributor Author

@moyodiallo moyodiallo Apr 3, 2024

Choose a reason for hiding this comment

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

This was commented by @kit-ty-kate. It's about avoiding regression in the future. Maybe we could refactor it like source.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 29bc4a5.

Copy link
Member

Choose a reason for hiding this comment

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

why is it not needed? I'm not seeing that test in source.test (which also isn't really the place to test for this if it was there)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, I've just realized that I'm mixing everything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Collaborator

@rjbou rjbou Apr 4, 2024

Choose a reason for hiding this comment

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

@kit-ty-kate what is the purpose of this test ? I'm guessing that it is to be sure that opam repo download is kept with --depth 1, is it? Its code path remain untouched, but indeed it calls VCS.fetch.

Copy link
Member

Choose a reason for hiding this comment

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

yeah exactly. So that if in the future the behaviour changes (by mistake or on purpose) we already have a test for it

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok! It needs then a comment to explain why it is here. I'll add it.

@kit-ty-kate kit-ty-kate requested a review from rjbou April 3, 2024 14:40
@rjbou rjbou changed the title opam source, fetched with --depth 1 could be avoided opam source --dev fetching git repositories without --depth 1 Apr 4, 2024
… when retrieved with `opam source --dev`, and no change for opam repository checkout

Co-authored-by: Raja Boujbel <raja.boujbel@ocamlpro.com>
Co-authored-by: Kate <kit-ty-kate@outlook.com>
Copy link
Collaborator

@rjbou rjbou left a comment

Choose a reason for hiding this comment

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

Thanks!

@kit-ty-kate
Copy link
Member

Thanks a lot!

@kit-ty-kate kit-ty-kate merged commit f7def5c into ocaml:master Apr 5, 2024
29 checks passed
@moyodiallo moyodiallo deleted the full-fetch branch May 24, 2024 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Have an option to disable git --depth 1 on opam source --dev
3 participants