Compare commits

..

4 Commits

Author SHA1 Message Date
techknowlogick
2903afb78f
Allow issue templates to not render title (#22589)
This adds a yaml attribute that will allow the option for when markdown
is rendered that the title will be not included in the output

Based on work from @brechtvl
2023-01-26 22:45:49 -06:00
John Olheiser
642db3c8f7
Fix delete_repo in template (#22606)
Currently the value doesn't match the model, so selecting it results in
a 500.

e8ac6a9aea/models/auth/token_scope.go (L42)

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-01-26 14:36:15 -06:00
yp05327
4f8c0eba9a
set org visibility class to basic in header (#22605)
Fixes https://github.com/go-gitea/gitea/issues/22601

At people and team page, we have red private tag or orange limited tag,
but at repo page, it is gray (basic).
I think it is better to set them into same color (basic).
2023-01-26 12:44:34 -06:00
JakobDev
4d072a4c4e
Add API endpoint to get latest release (#21267)
This PR adds a new API endpoint to get the latest stable release of a
repo, similar to [GitHub
API](https://docs.github.com/en/rest/releases/releases#get-the-latest-release).
2023-01-26 10:33:47 -06:00
8 changed files with 110 additions and 6 deletions

View File

@ -259,7 +259,9 @@ func (f *valuedField) WriteTo(builder *strings.Builder) {
} }
// write label // write label
if !f.HideLabel() {
_, _ = fmt.Fprintf(builder, "### %s\n\n", f.Label()) _, _ = fmt.Fprintf(builder, "### %s\n\n", f.Label())
}
blankPlaceholder := "_No response_\n" blankPlaceholder := "_No response_\n"
@ -311,6 +313,13 @@ func (f *valuedField) Label() string {
return "" return ""
} }
func (f *valuedField) HideLabel() bool {
if label, ok := f.Attributes["hide_label"].(bool); ok {
return label
}
return false
}
func (f *valuedField) Render() string { func (f *valuedField) Render() string {
if render, ok := f.Attributes["render"].(string); ok { if render, ok := f.Attributes["render"].(string); ok {
return render return render

View File

@ -640,6 +640,7 @@ body:
description: Description of input description: Description of input
placeholder: Placeholder of input placeholder: Placeholder of input
value: Value of input value: Value of input
hide_label: true
validations: validations:
required: true required: true
is_number: true is_number: true
@ -681,8 +682,6 @@ body:
` + "```bash\nValue of id2\n```" + ` ` + "```bash\nValue of id2\n```" + `
### Label of input
Value of id3 Value of id3
### Label of dropdown ### Label of dropdown

View File

@ -1011,6 +1011,7 @@ func Routes(ctx gocontext.Context) *web.Route {
m.Group("/releases", func() { m.Group("/releases", func() {
m.Combo("").Get(repo.ListReleases). m.Combo("").Get(repo.ListReleases).
Post(reqToken(auth_model.AccessTokenScopeRepo), reqRepoWriter(unit.TypeReleases), context.ReferencesGitRepo(), bind(api.CreateReleaseOption{}), repo.CreateRelease) Post(reqToken(auth_model.AccessTokenScopeRepo), reqRepoWriter(unit.TypeReleases), context.ReferencesGitRepo(), bind(api.CreateReleaseOption{}), repo.CreateRelease)
m.Combo("/latest").Get(repo.GetLatestRelease)
m.Group("/{id}", func() { m.Group("/{id}", func() {
m.Combo("").Get(repo.GetRelease). m.Combo("").Get(repo.GetRelease).
Patch(reqToken(auth_model.AccessTokenScopeRepo), reqRepoWriter(unit.TypeReleases), context.ReferencesGitRepo(), bind(api.EditReleaseOption{}), repo.EditRelease). Patch(reqToken(auth_model.AccessTokenScopeRepo), reqRepoWriter(unit.TypeReleases), context.ReferencesGitRepo(), bind(api.EditReleaseOption{}), repo.EditRelease).

View File

@ -67,6 +67,47 @@ func GetRelease(ctx *context.APIContext) {
ctx.JSON(http.StatusOK, convert.ToRelease(release)) ctx.JSON(http.StatusOK, convert.ToRelease(release))
} }
// GetLatestRelease gets the most recent non-prerelease, non-draft release of a repository, sorted by created_at
func GetLatestRelease(ctx *context.APIContext) {
// swagger:operation GET /repos/{owner}/{repo}/releases/latest repository repoGetLatestRelease
// ---
// summary: Gets the most recent non-prerelease, non-draft release of a repository, sorted by created_at
// produces:
// - application/json
// parameters:
// - name: owner
// in: path
// description: owner of the repo
// type: string
// required: true
// - name: repo
// in: path
// description: name of the repo
// type: string
// required: true
// responses:
// "200":
// "$ref": "#/responses/Release"
// "404":
// "$ref": "#/responses/notFound"
release, err := repo_model.GetLatestReleaseByRepoID(ctx.Repo.Repository.ID)
if err != nil && !repo_model.IsErrReleaseNotExist(err) {
ctx.Error(http.StatusInternalServerError, "GetLatestRelease", err)
return
}
if err != nil && repo_model.IsErrReleaseNotExist(err) ||
release.IsTag || release.RepoID != ctx.Repo.Repository.ID {
ctx.NotFound()
return
}
if err := release.LoadAttributes(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
return
}
ctx.JSON(http.StatusOK, convert.ToRelease(release))
}
// ListReleases list a repository's releases // ListReleases list a repository's releases
func ListReleases(ctx *context.APIContext) { func ListReleases(ctx *context.APIContext) {
// swagger:operation GET /repos/{owner}/{repo}/releases repository repoListReleases // swagger:operation GET /repos/{owner}/{repo}/releases repository repoListReleases

View File

@ -6,8 +6,8 @@
{{avatar . 100}} {{avatar . 100}}
<span class="text thin grey"><a href="{{.HomeLink}}">{{.DisplayName}}</a></span> <span class="text thin grey"><a href="{{.HomeLink}}">{{.DisplayName}}</a></span>
<span class="org-visibility"> <span class="org-visibility">
{{if .Visibility.IsLimited}}<div class="ui medium orange horizontal label">{{$.locale.Tr "org.settings.visibility.limited_shortname"}}</div>{{end}} {{if .Visibility.IsLimited}}<div class="ui medium basic horizontal label">{{$.locale.Tr "org.settings.visibility.limited_shortname"}}</div>{{end}}
{{if .Visibility.IsPrivate}}<div class="ui medium red horizontal label">{{$.locale.Tr "org.settings.visibility.private_shortname"}}</div>{{end}} {{if .Visibility.IsPrivate}}<div class="ui medium basic horizontal label">{{$.locale.Tr "org.settings.visibility.private_shortname"}}</div>{{end}}
</span> </span>
</div> </div>
</div> </div>

View File

@ -9776,6 +9776,42 @@
} }
} }
}, },
"/repos/{owner}/{repo}/releases/latest": {
"get": {
"produces": [
"application/json"
],
"tags": [
"repository"
],
"summary": "Gets the most recent non-prerelease, non-draft release of a repository, sorted by created_at",
"operationId": "repoGetLatestRelease",
"parameters": [
{
"type": "string",
"description": "owner of the repo",
"name": "owner",
"in": "path",
"required": true
},
{
"type": "string",
"description": "name of the repo",
"name": "repo",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"$ref": "#/responses/Release"
},
"404": {
"$ref": "#/responses/notFound"
}
}
}
},
"/repos/{owner}/{repo}/releases/tags/{tag}": { "/repos/{owner}/{repo}/releases/tags/{tag}": {
"get": { "get": {
"produces": [ "produces": [

View File

@ -165,7 +165,7 @@
</div> </div>
<div class="field"> <div class="field">
<div class="ui checkbox"> <div class="ui checkbox">
<input class="enable-system" type="checkbox" name="scope" value="delete:repo"> <input class="enable-system" type="checkbox" name="scope" value="delete_repo">
<label>delete_repo</label> <label>delete_repo</label>
</div> </div>
</div> </div>

View File

@ -176,6 +176,24 @@ func TestAPICreateReleaseToDefaultBranchOnExistingTag(t *testing.T) {
createNewReleaseUsingAPI(t, session, token, owner, repo, "v0.0.1", "", "v0.0.1", "test") createNewReleaseUsingAPI(t, session, token, owner, repo, "v0.0.1", "", "v0.0.1", "test")
} }
func TestAPIGetLatestRelease(t *testing.T) {
defer tests.PrepareTestEnv(t)()
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/releases/latest",
owner.Name, repo.Name)
req := NewRequestf(t, "GET", urlStr)
resp := MakeRequest(t, req, http.StatusOK)
var release *api.Release
DecodeJSON(t, resp, &release)
assert.Equal(t, "testing-release", release.Title)
}
func TestAPIGetReleaseByTag(t *testing.T) { func TestAPIGetReleaseByTag(t *testing.T) {
defer tests.PrepareTestEnv(t)() defer tests.PrepareTestEnv(t)()