-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
feat: expose url field on issue api. #982
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
Conversation
|
This would be better include in 1.1.0 release. |
|
Let's decided it before release |
|
@lunny OK |
|
trusted LGTM |
models/issue.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about that. From GitHub's API it seems that it should be the API URL to get the issue, not the HTML URL: https://developer.github.com/v3/issues/#get-a-single-issue
"url": "https://api.github.com/repos/octocat/Hello-World/issues/1347",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't we define the API URL for Gitea? cc @lunny
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed it is the API-URL :) and that function doesn't exist, so we need a issue.APIURL() as well (should be fairly simple)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@appleboy It seems there is not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we didn't have API URL in app.ini, we only have ROOT_URL config now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't support a separate api url yet, so just take the regular url and append the api path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func (i *Issue) APIURL() string {
return path.Join(settings.AppURL, "/api/v1/repos/", issue.Repo.FullName(), "issues", issue.ID)
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preferably there should be 2 new functions:
func (repo *Repo) APIURL() string {
return path.Join(settings.AppURL, "/api/v1/repos/", repo.FullName())
}
func (issue *Issue) APIURL() string {
return path.Join(issue.Repo.APIURL(), "issues", issue.ID)
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bkcsoft maybe you can send a PR and we can close this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will update this PR.
|
build failed. |
|
LGTM when the build succeeds :) |
Need to |
models/repo.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does appurl include the sub path of gitea is not running on the top folder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. path.Join will convert double slash to single slash.
|
I will fix errors. Please wait. |
86484f2 to
23285b6
Compare
|
Add unit testing. |
models/repo.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Support setting.AppURL include end slash or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for that, path.Join does that automagically 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bkcsoft path.Join will replace // with /
setting.AppURL = "https://try.gitea.io/"
path.Join(setting.AppURL, "api/v1/repos", repo.FullName())
# output: https:/try.gitea.io/api/v1/repos/user01/testThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, path.Join destroys absolute urls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how that is relevant, it's supposed to be an absolute URL, not a relative one.
Works just fine IMO: https://play.golang.org/p/Rc734RIuJu
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bkcsoft Please see the result from your url
https:/try.gitea.io/api/v1/repos/user01/repo01
Wrong: https:/
Correct: https://
|
LGTM |
models/issue.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary, path.Join trims extra slashes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same above.
|
conflicted. |
|
@lunny fix conflicts and wait for build status. |
|
LGTM |
d4f04aa to
623aed4
Compare
|
@appleboy maybe you should rebase and push --force. |
|
@lunny I always use |
models/repo_test.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing output lint errors after execute make lint command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linting doesn't apply to *_test.go 🙂
models/issue_test.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this test renamed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that the naming conventions for tests were the same as the convetions for testable examples (https://blog.golang.org/examples)? Was I mistaken?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ethantkoenig revert.
|
need @ethantkoenig confirmation. |
|
Thanks @appleboy! ❤️ |
fix #402