Skip to content

repo: remotes family: implement list/get-url/set-url #67

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

Merged
merged 10 commits into from
Feb 25, 2022
Merged

repo: remotes family: implement list/get-url/set-url #67

merged 10 commits into from
Feb 25, 2022

Conversation

jtagcat
Copy link
Contributor

@jtagcat jtagcat commented Jan 23, 2022

edit: ready to review

@jtagcat
Copy link
Contributor Author

jtagcat commented Jan 23, 2022

Because of

  • Autocomplete
  • Hirearchy
  • Following upstream (git bin)

It'd make sense to use RemotesList instead of ListRemotes; the same with RemoteURLGet and RemoteURLSet (used here) vs GetRemoteURL and SetRemoteURL (style in file).

Are style for func names enforced? I didn't follow the exact naming in the same file.

@jtagcat
Copy link
Contributor Author

jtagcat commented Jan 23, 2022

force-pushes:

  • moved a part to utils.go; reusing it
  • fixed mistake in swapping got-want in some assertions
  • renamed ListRemotes() to RemotesList(), see above

@jtagcat jtagcat changed the title repo: add ListRemotes() repo: add ListRemotes() and remote get-url/set-url family Jan 23, 2022
@jtagcat jtagcat changed the title repo: add ListRemotes() and remote get-url/set-url family repo: remotes family: add list/get-url/set-url Jan 23, 2022
@jtagcat jtagcat changed the title repo: remotes family: add list/get-url/set-url repo: remotes family: implement list/get-url/set-url Jan 23, 2022
@jtagcat
Copy link
Contributor Author

jtagcat commented Feb 9, 2022

@unknwon PTAL, planning to do similar PRs for additional commands.

@unknwon
Copy link
Member

unknwon commented Feb 10, 2022

It'd make sense to use RemotesList instead of ListRemotes; the same with RemoteURLGet and RemoteURLSet (used here) vs GetRemoteURL and SetRemoteURL (style in file).

Are style for func names enforced? I didn't follow the exact naming in the same file.

No there is no existing enforced naming convention, but I think your idea of being closer to how a user would use Git bin makes total sense 👍

Copy link
Member

@unknwon unknwon 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 the PR! Overall looking good 🤩 Mostly convention issues.

repo_remote.go Outdated
Comment on lines 229 to 230
// RepoRemoteURLSetFirst sets first URL of the remote with given name of the repository in given path.
func RepoRemoteURLSetFirst(repoPath, name, newurl string, opts ...RemoteURLSetOptions) error {
Copy link
Member

Choose a reason for hiding this comment

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

How is the "first" come into play? Not seeing "first" is used as git args?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

uhh yeah so.. repo can have like
origin urls:

  • type fetch url: foobar1
  • type push url: foobar2
  • type fetch url: foobar3
  • type fetch url: foobar4

^^^ in this case, the first fetch url is foobar1, and first push url is foobar3

In reality, this almost never happens, and even if it does, the 'first' is used elsewhere as well.

It might be a good idea to add a short 'it is almost always first, and if not, you probably don't have to worry', but don't know on how to word it.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the context!

Either way I think we do not need explicitly put "first" in our function name because we are basically pass-on the value from Git CLI, and whatever it returns is what we return to the caller.

@jtagcat jtagcat requested a review from unknwon February 11, 2022 16:16
Copy link
Member

@unknwon unknwon left a comment

Choose a reason for hiding this comment

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

Sorry about delayed response 😅

repo_remote.go Outdated
Comment on lines 229 to 230
// RepoRemoteURLSetFirst sets first URL of the remote with given name of the repository in given path.
func RepoRemoteURLSetFirst(repoPath, name, newurl string, opts ...RemoteURLSetOptions) error {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the context!

Either way I think we do not need explicitly put "first" in our function name because we are basically pass-on the value from Git CLI, and whatever it returns is what we return to the caller.

@jtagcat
Copy link
Contributor Author

jtagcat commented Feb 24, 2022

All bool #67 (comment)

I can't see how, but I improved the wording nevertheless.

edit: True: part probably, removed it.

Push bool #67 (comment)

fixed

Either way I think we do not need explicitly put "first" in our function name because we are basically pass-on the value from Git CLI, and whatever it returns is what we return to the caller.

s/SetFirst/Set/g done

Let's all-in to follow how we use git bin!

s/URLGet/GetURL/g, s/URLSet/SetURL/g


also jfyi you can make direct edits in the PR as you see fit

@jtagcat jtagcat requested a review from unknwon February 24, 2022 20:29
Copy link
Member

@unknwon unknwon left a comment

Choose a reason for hiding this comment

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

Thanks again for the follow up!

@unknwon
Copy link
Member

unknwon commented Feb 25, 2022

I made a push in 1e5f3c2, LMK if you have any questions, otherwise I'm going to merge once looks good to you!

@jtagcat
Copy link
Contributor Author

jtagcat commented Feb 25, 2022

image

Made a small change for the comment at here: Add bool

@jtagcat
Copy link
Contributor Author

jtagcat commented Feb 25, 2022

RemoteSetURLDelete seems odd for me, RemoteDeleteURL is better imo (even though it does not exactly follow git-bin)?

@jtagcat
Copy link
Contributor Author

jtagcat commented Feb 25, 2022

suggested refactor out of this PR:

type RemotesOptions struct {
	// The timeout duration before giving up for each shell command execution.
	// The default timeout duration will be used when not supplied.
	Timeout time.Duration
}

You can just do

type DefaultOptions struct {
	// The timeout duration before giving up for each shell command execution.
	// The default timeout duration will be used when not supplied.
	Timeout time.Duration
}

// and for each:
var RemotesOptions DefaultOptions

@unknwon
Copy link
Member

unknwon commented Feb 25, 2022

// and for each:
var RemotesOptions DefaultOptions

How will RemotesOptions be used look like? Also, do you mean type RemotesOptions DefaultOptions?

@jtagcat
Copy link
Contributor Author

jtagcat commented Feb 25, 2022

How will RemotesOptions be used look like?

It will be the same to the user, if anything is added later, you can change it from DefaultOptions to something different.

Using type RemoteOptions DefaultOptions, it's like a symlink pretty much.

Also, do you mean type RemotesOptions DefaultOptions?

yes, oops

@unknwon
Copy link
Member

unknwon commented Feb 25, 2022

How will RemotesOptions be used look like?

It will be the same to the user, if anything is added later, you can change it from DefaultOptions to something different.

Using type RemoteOptions DefaultOptions, it's like a symlink pretty much.

Also, do you mean type RemotesOptions DefaultOptions?

yes, oops

Yeah, SGTM! Let's do this in another PR.


As for this PR, I think once we bring back the RemoteSetURLAdd, we're good to go!

@jtagcat
Copy link
Contributor Author

jtagcat commented Feb 25, 2022

Add does not take any regex.

See #67 (comment)

image

Either adding the comment, or actually doing static checking would be nice.

@jtagcat
Copy link
Contributor Author

jtagcat commented Feb 25, 2022

As for this PR, I think once we bring back the RemoteSetURLAdd, we're good to go!

okie then

@jtagcat
Copy link
Contributor Author

jtagcat commented Feb 25, 2022

LGTM @unknwon

@unknwon
Copy link
Member

unknwon commented Feb 25, 2022

Let's wait for the CI!

@unknwon unknwon merged commit 9a01961 into gogs:master Feb 25, 2022
@unknwon
Copy link
Member

unknwon commented Feb 25, 2022

https://github.com/gogs/git-module/releases/tag/v1.2.0 has been tagged for this merge.

@jtagcat jtagcat deleted the listremotes branch February 25, 2022 20:28
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.

2 participants