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: Use the 'user' option as the fork owner #480

Merged
merged 3 commits into from
Jan 19, 2024

Conversation

Julow
Copy link
Member

@Julow Julow commented Jul 18, 2023

This is an attempt at fixing #479 but I noticed that the user option is deprecated.

Decoding the remote URL can easily fail, instead let the user provide the correct username to use in API calls.

Only attempt to decode the remote URL if the user option is not set. The error message is changed to encourage setting the user option instead of asking users to change their URLs.

@Leonidas-from-XIV
Copy link
Member

Hmm, yeah, this approach in general seems reasonable to me. I think the idea was that for 80% of users no configuration is required and it can be inferred but you're right that it is not a 100% solution so being able to explicitly provide the user sounds like a good option to me.

@Julow
Copy link
Member Author

Julow commented Jul 19, 2023

It seems that the user option has been deprecated both because it is redundant with the remote URL and because it could have an inconsistent value with it. I show that it's not redundant but the other issue remains.

The problem I can see is pushing the changes to repo userA/opam-repository but opening the PR from branch userB:branch, which would fail saying the branch doesn't exist. This might be fixed by your proposal of using the API instead of a local repo in #479 ?

@Julow Julow marked this pull request as ready for review July 19, 2023 13:08
@Leonidas-from-XIV
Copy link
Member

This might be fixed by your proposal of using the API instead of a local repo in #479 ?

I do hope so, however depending on whether we still want to support local repos (I would say no, others might disagree) this might not be a complete solution.

@Julow
Copy link
Member Author

Julow commented Dec 11, 2023

This has slowed me down in release Odoc today.

@gpetiot
Copy link
Member

gpetiot commented Jan 17, 2024

I dug around and I didn't find anything in the API that would allow to do that without the username/ownername (with just the url as you suggested @Leonidas-from-XIV), what we are doing right now (https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#create-a-pull-request) looks like the only way.

@Leonidas-from-XIV do you have more details about what you suggested, or more concerns about this PR?
From where I'm at, it looks like the best solution to #479, and we could merge it.

Copy link
Member

@Leonidas-from-XIV Leonidas-from-XIV left a comment

Choose a reason for hiding this comment

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

Can you also add a changelog entry to the PR?

bin/opam.ml Outdated Show resolved Hide resolved
bin/opam.ml Outdated Show resolved Hide resolved
Julow and others added 3 commits January 19, 2024 12:22
Decoding the remote URL can easily fail, instead let the user provide
the correct username to use in API calls.

Only attempt to decode the remote URL if the 'user' option is not set.
The error message is changed to encourage setting the 'user' option
instead of asking users to change their URLs.
@gpetiot
Copy link
Member

gpetiot commented Jan 19, 2024

I modified the code according to the review and added an entry in the changelog.

@Leonidas-from-XIV Leonidas-from-XIV merged commit 348fc1e into tarides:main Jan 19, 2024
3 checks passed
@Leonidas-from-XIV
Copy link
Member

LGTM, thanks!

Copy link
Member Author

@Julow Julow left a comment

Choose a reason for hiding this comment

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

Thanks!

@@ -164,19 +165,25 @@ let open_pr ~dry_run ~changes ~remote_repo ~fork_owner ~branch ~token ~title
| Ok () -> Ok 0
| Error _ -> msg ())

let parse_remote_repo remote_repo =
(** Get the value from the [user] config, if it is unset try to parse it from
Copy link
Member Author

Choose a reason for hiding this comment

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

The docstring is now wrong.

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.

3 participants