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

feat: infer gitea api_domain from domain, if unspecified. #675

Merged

Conversation

lukester1975
Copy link
Contributor

Hello again

For a gitea repo how about implying the api_domain (when not specified) from domain? Saves a bit more config.

Thanks

PS how about inferring domain itself (when not provided) from pyproject.toml project.urls.repository (if provided)? I had a quick look but given the code drops everything but [tool.semantic_release] from pyproject.toml immediately after parsing it, the change seemed like more than a one-liner. Happy to have a look if you think it's sensible.

@lukester1975 lukester1975 force-pushed the imply-gitea-api-domain branch 2 times, most recently from 7467cbf to 077f0c0 Compare August 12, 2023 08:06
Copy link
Contributor

@bernardcooke53 bernardcooke53 left a comment

Choose a reason for hiding this comment

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

The change looks good @lukester1975 - would you mind adding a change to the docs explaining that this can be inferred for Gitea servers?

@bernardcooke53
Copy link
Contributor

Also re: your PS - as you say, I'm sure it's more than a one-line change. I think it's a nice idea, though, as long as the configuration parsing doesn't get super complex as a result

@lukester1975
Copy link
Contributor Author

lukester1975 commented Aug 27, 2023

I think I did look but couldn't see any existing documentation for domain and api_domain so thought maybe just the changelog would suffice, but maybe I missed it?

@lukester1975
Copy link
Contributor Author

Also re: your PS - as you say, I'm sure it's more than a one-line change. I think it's a nice idea, though, as long as the configuration parsing doesn't get super complex as a result

Struck me there's a simpler (almost 1 line) approach: lukester1975@907840f

That said I don't think it's correct if the http access is via a subpath.

E.g. remote_url: ssh://gitea@my.server/org/repo-name
http url: https://my.server/gitea/org/repo-name

No way to infer that /gitea subpath component of the http path. But then the existing config option is available...

If you think this is a non-starter I'll see if I can find time to dig out the url from pyproject.toml.

Thanks

@bernardcooke53
Copy link
Contributor

You're right, the options should be under the remote table but aren't yet.

Was thinking through the relative tradeoff between being simple and explicit (maybe causing duplication) and convenience having things auto-detected.
Could be sensible to do the following:
Try to derive api_domain from domain using some sensible defaults, if the config option is missing - those would be api.{domain} for GitHub, {domain}/api/v4 for Gitlab and {domain}/api/v1 for Gitea. In addition, we could try to detect domain from the following locations in order:

  1. the remote.domain config option
  2. git config --get remote.{name}.url, where {name} is the remote.name config option
  3. project.urls.repository

That way we'd have a sensible set of locations and defaults, but we're somewhat consistent in how things are detected and when you have to specify things. Not suggesting all that has to go into a PR here, but keen to hear what you think 🙂

@lukester1975
Copy link
Contributor Author

Probably put 3 before 2 due to the ssh/https issue and subpaths?

@codejedi365 codejedi365 merged commit 2ee3f8a into python-semantic-release:master Mar 31, 2024
7 checks passed
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.

None yet

3 participants