feat: expose url field on issue api.#982
Conversation
|
This would be better include in 1.1.0 release. |
|
Let's decided it before release |
|
@lunny OK |
|
trusted LGTM |
There was a problem hiding this comment.
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.
Didn't we define the API URL for Gitea? cc @lunny
There was a problem hiding this comment.
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.
But we didn't have API URL in app.ini, we only have ROOT_URL config now.
There was a problem hiding this comment.
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.
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.
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.
@bkcsoft maybe you can send a PR and we can close this one.
|
build failed. |
|
LGTM when the build succeeds :) |
Need to |
There was a problem hiding this comment.
Does appurl include the sub path of gitea is not running on the top folder?
There was a problem hiding this comment.
Good catch. path.Join will convert double slash to single slash.
|
I will fix errors. Please wait. |
86484f2 to
23285b6
Compare
|
Add unit testing. |
There was a problem hiding this comment.
Support setting.AppURL include end slash or not
There was a problem hiding this comment.
No need for that, path.Join does that automagically 🙂
There was a problem hiding this comment.
@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.
Yeah, path.Join destroys absolute urls.
There was a problem hiding this comment.
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.
@bkcsoft Please see the result from your url
https:/try.gitea.io/api/v1/repos/user01/repo01
Wrong: https:/
Correct: https://
|
LGTM |
There was a problem hiding this comment.
Unnecessary, path.Join trims extra slashes
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Nothing output lint errors after execute make lint command.
There was a problem hiding this comment.
Linting doesn't apply to *_test.go 🙂
There was a problem hiding this comment.
There was a problem hiding this comment.
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?
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
|
need @ethantkoenig confirmation. |
|
Thanks @appleboy! ❤️ |
fix #402