Compare commits

..

No commits in common. "6375419468edc95fdfac94aac3b0e10b23743557" and "b1eb1676aa95d776ff9085002641ad62e040cd93" have entirely different histories.

93 changed files with 845 additions and 1145 deletions

View File

@ -53,4 +53,3 @@ wxiaoguang <wxiaoguang@gmail.com> (@wxiaoguang)
Gary Moon <gary@garymoon.net> (@garymoon) Gary Moon <gary@garymoon.net> (@garymoon)
Philip Peterson <philip.c.peterson@gmail.com> (@philip-peterson) Philip Peterson <philip.c.peterson@gmail.com> (@philip-peterson)
Denys Konovalov <kontakt@denyskon.de> (@denyskon) Denys Konovalov <kontakt@denyskon.de> (@denyskon)
Punit Inani <punitinani1@gmail.com> (@puni9869)

View File

@ -455,9 +455,9 @@ func hashAndVerifyForKeyID(sig *packet.Signature, payload string, committer *use
// CalculateTrustStatus will calculate the TrustStatus for a commit verification within a repository // CalculateTrustStatus will calculate the TrustStatus for a commit verification within a repository
// There are several trust models in Gitea // There are several trust models in Gitea
func CalculateTrustStatus(verification *CommitVerification, repoTrustModel repo_model.TrustModelType, isOwnerMemberCollaborator func(*user_model.User) (bool, error), keyMap *map[string]bool) error { func CalculateTrustStatus(verification *CommitVerification, repoTrustModel repo_model.TrustModelType, isOwnerMemberCollaborator func(*user_model.User) (bool, error), keyMap *map[string]bool) (err error) {
if !verification.Verified { if !verification.Verified {
return nil return
} }
// In the Committer trust model a signature is trusted if it matches the committer // In the Committer trust model a signature is trusted if it matches the committer
@ -475,7 +475,7 @@ func CalculateTrustStatus(verification *CommitVerification, repoTrustModel repo_
verification.SigningUser.Email == verification.CommittingUser.Email) { verification.SigningUser.Email == verification.CommittingUser.Email) {
verification.TrustStatus = "trusted" verification.TrustStatus = "trusted"
} }
return nil return
} }
// Now we drop to the more nuanced trust models... // Now we drop to the more nuanced trust models...
@ -490,11 +490,10 @@ func CalculateTrustStatus(verification *CommitVerification, repoTrustModel repo_
verification.SigningUser.Email != verification.CommittingUser.Email) { verification.SigningUser.Email != verification.CommittingUser.Email) {
verification.TrustStatus = "untrusted" verification.TrustStatus = "untrusted"
} }
return nil return
} }
// Check we actually have a GPG SigningKey // Check we actually have a GPG SigningKey
var err error
if verification.SigningKey != nil { if verification.SigningKey != nil {
var isMember bool var isMember bool
if keyMap != nil { if keyMap != nil {

View File

@ -306,10 +306,9 @@ func (code *OAuth2AuthorizationCode) TableName() string {
} }
// GenerateRedirectURI generates a redirect URI for a successful authorization request. State will be used if not empty. // GenerateRedirectURI generates a redirect URI for a successful authorization request. State will be used if not empty.
func (code *OAuth2AuthorizationCode) GenerateRedirectURI(state string) (*url.URL, error) { func (code *OAuth2AuthorizationCode) GenerateRedirectURI(state string) (redirect *url.URL, err error) {
redirect, err := url.Parse(code.RedirectURI) if redirect, err = url.Parse(code.RedirectURI); err != nil {
if err != nil { return
return nil, err
} }
q := redirect.Query() q := redirect.Query()
if state != "" { if state != "" {

View File

@ -15,8 +15,6 @@ import (
"code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/util"
"xorm.io/builder"
) )
// ErrBranchNotExist represents an error that branch with such name does not exist. // ErrBranchNotExist represents an error that branch with such name does not exist.
@ -380,22 +378,3 @@ func RenameBranch(ctx context.Context, repo *repo_model.Repository, from, to str
return committer.Commit() return committer.Commit()
} }
// FindRecentlyPushedNewBranches return at most 2 new branches pushed by the user in 6 hours which has no opened PRs created
func FindRecentlyPushedNewBranches(ctx context.Context, repoID, userID int64) (BranchList, error) {
branches := make(BranchList, 0, 2)
subQuery := builder.Select("head_branch").From("pull_request").
InnerJoin("issue", "issue.id = pull_request.issue_id").
Where(builder.Eq{
"pull_request.head_repo_id": repoID,
"issue.is_closed": false,
})
err := db.GetEngine(ctx).
Where("pusher_id=? AND is_deleted=?", userID, false).
And("updated_unix >= ?", time.Now().Add(-time.Hour*6).Unix()).
NotIn("name", subQuery).
OrderBy("branch.updated_unix DESC").
Limit(2).
Find(&branches)
return branches, err
}

View File

@ -16,10 +16,10 @@ type Watch struct {
Mode RepoWatchMode `xorm:"SMALLINT NOT NULL DEFAULT 1"` Mode RepoWatchMode `xorm:"SMALLINT NOT NULL DEFAULT 1"`
} }
func AddModeColumnToWatch(x *xorm.Engine) error { func AddModeColumnToWatch(x *xorm.Engine) (err error) {
if err := x.Sync2(new(Watch)); err != nil { if err = x.Sync2(new(Watch)); err != nil {
return err return
} }
_, err := x.Exec("UPDATE `watch` SET `mode` = 1") _, err = x.Exec("UPDATE `watch` SET `mode` = 1")
return err return err
} }

View File

@ -23,25 +23,25 @@ func RecalculateStars(x *xorm.Engine) (err error) {
for start := 0; ; start += batchSize { for start := 0; ; start += batchSize {
users := make([]User, 0, batchSize) users := make([]User, 0, batchSize)
if err := sess.Limit(batchSize, start).Where("type = ?", 0).Cols("id").Find(&users); err != nil { if err = sess.Limit(batchSize, start).Where("type = ?", 0).Cols("id").Find(&users); err != nil {
return err return
} }
if len(users) == 0 { if len(users) == 0 {
break break
} }
if err := sess.Begin(); err != nil { if err = sess.Begin(); err != nil {
return err return
} }
for _, user := range users { for _, user := range users {
if _, err := sess.Exec("UPDATE `user` SET num_stars=(SELECT COUNT(*) FROM `star` WHERE uid=?) WHERE id=?", user.ID, user.ID); err != nil { if _, err = sess.Exec("UPDATE `user` SET num_stars=(SELECT COUNT(*) FROM `star` WHERE uid=?) WHERE id=?", user.ID, user.ID); err != nil {
return err return
} }
} }
if err := sess.Commit(); err != nil { if err = sess.Commit(); err != nil {
return err return
} }
} }

View File

@ -44,25 +44,25 @@ func DeleteMigrationCredentials(x *xorm.Engine) (err error) {
for start := 0; ; start += batchSize { for start := 0; ; start += batchSize {
tasks := make([]*Task, 0, batchSize) tasks := make([]*Task, 0, batchSize)
if err := sess.Limit(batchSize, start).Where(cond, 0).Find(&tasks); err != nil { if err = sess.Limit(batchSize, start).Where(cond, 0).Find(&tasks); err != nil {
return err return
} }
if len(tasks) == 0 { if len(tasks) == 0 {
break break
} }
if err := sess.Begin(); err != nil { if err = sess.Begin(); err != nil {
return err return
} }
for _, t := range tasks { for _, t := range tasks {
if t.PayloadContent, err = removeCredentials(t.PayloadContent); err != nil { if t.PayloadContent, err = removeCredentials(t.PayloadContent); err != nil {
return err return
} }
if _, err := sess.ID(t.ID).Cols("payload_content").Update(t); err != nil { if _, err = sess.ID(t.ID).Cols("payload_content").Update(t); err != nil {
return err return
} }
} }
if err := sess.Commit(); err != nil { if err = sess.Commit(); err != nil {
return err return
} }
} }
return err return err

View File

@ -9,7 +9,7 @@ import (
"xorm.io/xorm" "xorm.io/xorm"
) )
func AddPrimaryEmail2EmailAddress(x *xorm.Engine) error { func AddPrimaryEmail2EmailAddress(x *xorm.Engine) (err error) {
type User struct { type User struct {
ID int64 `xorm:"pk autoincr"` ID int64 `xorm:"pk autoincr"`
Email string `xorm:"NOT NULL"` Email string `xorm:"NOT NULL"`
@ -26,12 +26,12 @@ func AddPrimaryEmail2EmailAddress(x *xorm.Engine) error {
} }
// Add lower_email and is_primary columns // Add lower_email and is_primary columns
if err := x.Table("email_address").Sync2(new(EmailAddress1)); err != nil { if err = x.Table("email_address").Sync2(new(EmailAddress1)); err != nil {
return err return
} }
if _, err := x.Exec("UPDATE email_address SET lower_email=LOWER(email), is_primary=?", false); err != nil { if _, err = x.Exec("UPDATE email_address SET lower_email=LOWER(email), is_primary=?", false); err != nil {
return err return
} }
type EmailAddress struct { type EmailAddress struct {
@ -44,8 +44,8 @@ func AddPrimaryEmail2EmailAddress(x *xorm.Engine) error {
} }
// change lower_email as unique // change lower_email as unique
if err := x.Sync2(new(EmailAddress)); err != nil { if err = x.Sync2(new(EmailAddress)); err != nil {
return err return
} }
sess := x.NewSession() sess := x.NewSession()
@ -55,33 +55,34 @@ func AddPrimaryEmail2EmailAddress(x *xorm.Engine) error {
for start := 0; ; start += batchSize { for start := 0; ; start += batchSize {
users := make([]*User, 0, batchSize) users := make([]*User, 0, batchSize)
if err := sess.Limit(batchSize, start).Find(&users); err != nil { if err = sess.Limit(batchSize, start).Find(&users); err != nil {
return err return
} }
if len(users) == 0 { if len(users) == 0 {
break break
} }
for _, user := range users { for _, user := range users {
exist, err := sess.Where("email=?", user.Email).Table("email_address").Exist() var exist bool
exist, err = sess.Where("email=?", user.Email).Table("email_address").Exist()
if err != nil { if err != nil {
return err return
} }
if !exist { if !exist {
if _, err := sess.Insert(&EmailAddress{ if _, err = sess.Insert(&EmailAddress{
UID: user.ID, UID: user.ID,
Email: user.Email, Email: user.Email,
LowerEmail: strings.ToLower(user.Email), LowerEmail: strings.ToLower(user.Email),
IsActivated: user.IsActive, IsActivated: user.IsActive,
IsPrimary: true, IsPrimary: true,
}); err != nil { }); err != nil {
return err return
} }
} else { } else {
if _, err := sess.Where("email=?", user.Email).Cols("is_primary").Update(&EmailAddress{ if _, err = sess.Where("email=?", user.Email).Cols("is_primary").Update(&EmailAddress{
IsPrimary: true, IsPrimary: true,
}); err != nil { }); err != nil {
return err return
} }
} }
} }

View File

@ -528,18 +528,6 @@ func (repo *Repository) ComposeCompareURL(oldCommitID, newCommitID string) strin
return fmt.Sprintf("%s/%s/compare/%s...%s", url.PathEscape(repo.OwnerName), url.PathEscape(repo.Name), util.PathEscapeSegments(oldCommitID), util.PathEscapeSegments(newCommitID)) return fmt.Sprintf("%s/%s/compare/%s...%s", url.PathEscape(repo.OwnerName), url.PathEscape(repo.Name), util.PathEscapeSegments(oldCommitID), util.PathEscapeSegments(newCommitID))
} }
func (repo *Repository) ComposeBranchCompareURL(baseRepo *Repository, branchName string) string {
if baseRepo == nil {
baseRepo = repo
}
var cmpBranchEscaped string
if repo.ID != baseRepo.ID {
cmpBranchEscaped = fmt.Sprintf("%s/%s:", url.PathEscape(repo.OwnerName), url.PathEscape(repo.Name))
}
cmpBranchEscaped = fmt.Sprintf("%s%s", cmpBranchEscaped, util.PathEscapeSegments(branchName))
return fmt.Sprintf("%s/compare/%s...%s", baseRepo.Link(), util.PathEscapeSegments(baseRepo.DefaultBranch), cmpBranchEscaped)
}
// IsOwnedBy returns true when user owns this repository // IsOwnedBy returns true when user owns this repository
func (repo *Repository) IsOwnedBy(userID int64) bool { func (repo *Repository) IsOwnedBy(userID int64) bool {
return repo.OwnerID == userID return repo.OwnerID == userID

View File

@ -23,6 +23,8 @@ import (
type DetectedWorkflow struct { type DetectedWorkflow struct {
EntryName string EntryName string
TriggerEvent string TriggerEvent string
Commit *git.Commit
Ref string
Content []byte Content []byte
} }
@ -118,6 +120,7 @@ func DetectWorkflows(commit *git.Commit, triggedEvent webhook_module.HookEventTy
dwf := &DetectedWorkflow{ dwf := &DetectedWorkflow{
EntryName: entry.Name(), EntryName: entry.Name(),
TriggerEvent: evt.Name, TriggerEvent: evt.Name,
Commit: commit,
Content: content, Content: content,
} }
workflows = append(workflows, dwf) workflows = append(workflows, dwf)
@ -332,15 +335,18 @@ func matchIssuesEvent(commit *git.Commit, issuePayload *api.IssuePayload, evt *j
} }
func matchPullRequestEvent(commit *git.Commit, prPayload *api.PullRequestPayload, evt *jobparser.Event) bool { func matchPullRequestEvent(commit *git.Commit, prPayload *api.PullRequestPayload, evt *jobparser.Event) bool {
acts := evt.Acts() // with no special filter parameters
activityTypeMatched := false if len(evt.Acts()) == 0 {
matchTimes := 0
if vals, ok := acts["types"]; !ok {
// defaultly, only pull request `opened`, `reopened` and `synchronized` will trigger workflow // defaultly, only pull request `opened`, `reopened` and `synchronized` will trigger workflow
// See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request // See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
activityTypeMatched = prPayload.Action == api.HookIssueSynchronized || prPayload.Action == api.HookIssueOpened || prPayload.Action == api.HookIssueReOpened return prPayload.Action == api.HookIssueSynchronized || prPayload.Action == api.HookIssueOpened || prPayload.Action == api.HookIssueReOpened
} else { }
matchTimes := 0
// all acts conditions should be satisfied
for cond, vals := range evt.Acts() {
switch cond {
case "types":
// See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request // See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
// Actions with the same name: // Actions with the same name:
// opened, edited, closed, reopened, assigned, unassigned // opened, edited, closed, reopened, assigned, unassigned
@ -363,16 +369,10 @@ func matchPullRequestEvent(commit *git.Commit, prPayload *api.PullRequestPayload
log.Trace("matching pull_request %s with %v", action, vals) log.Trace("matching pull_request %s with %v", action, vals)
for _, val := range vals { for _, val := range vals {
if glob.MustCompile(val, '/').Match(string(action)) { if glob.MustCompile(val, '/').Match(string(action)) {
activityTypeMatched = true
matchTimes++ matchTimes++
break break
} }
} }
}
// all acts conditions should be satisfied
for cond, vals := range acts {
switch cond {
case "branches": case "branches":
refName := git.RefName(prPayload.PullRequest.Base.Ref) refName := git.RefName(prPayload.PullRequest.Base.Ref)
patterns, err := workflowpattern.CompilePatterns(vals...) patterns, err := workflowpattern.CompilePatterns(vals...)
@ -421,7 +421,7 @@ func matchPullRequestEvent(commit *git.Commit, prPayload *api.PullRequestPayload
log.Warn("pull request event unsupported condition %q", cond) log.Warn("pull request event unsupported condition %q", cond)
} }
} }
return activityTypeMatched && matchTimes == len(evt.Acts()) return matchTimes == len(evt.Acts())
} }
func matchIssueCommentEvent(commit *git.Commit, issueCommentPayload *api.IssueCommentPayload, evt *jobparser.Event) bool { func matchIssueCommentEvent(commit *git.Commit, issueCommentPayload *api.IssueCommentPayload, evt *jobparser.Event) bool {

View File

@ -57,25 +57,6 @@ func TestDetectMatched(t *testing.T) {
yamlOn: "on: pull_request", yamlOn: "on: pull_request",
expected: false, expected: false,
}, },
{
desc: "HookEventPullRequest(pull_request) `closed` action doesn't match GithubEventPullRequest(pull_request) with no activity type",
triggedEvent: webhook_module.HookEventPullRequest,
payload: &api.PullRequestPayload{Action: api.HookIssueClosed},
yamlOn: "on: pull_request",
expected: false,
},
{
desc: "HookEventPullRequest(pull_request) `closed` action doesn't match GithubEventPullRequest(pull_request) with branches",
triggedEvent: webhook_module.HookEventPullRequest,
payload: &api.PullRequestPayload{
Action: api.HookIssueClosed,
PullRequest: &api.PullRequest{
Base: &api.PRBranchInfo{},
},
},
yamlOn: "on:\n pull_request:\n branches: [main]",
expected: false,
},
{ {
desc: "HookEventPullRequest(pull_request) `label_updated` action matches GithubEventPullRequest(pull_request) with `label` activity type", desc: "HookEventPullRequest(pull_request) `label_updated` action matches GithubEventPullRequest(pull_request) with `label` activity type",
triggedEvent: webhook_module.HookEventPullRequest, triggedEvent: webhook_module.HookEventPullRequest,

View File

@ -422,10 +422,10 @@ func RepoIDAssignment() func(ctx *Context) {
} }
// RepoAssignment returns a middleware to handle repository assignment // RepoAssignment returns a middleware to handle repository assignment
func RepoAssignment(ctx *Context) context.CancelFunc { func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
if _, repoAssignmentOnce := ctx.Data["repoAssignmentExecuted"]; repoAssignmentOnce { if _, repoAssignmentOnce := ctx.Data["repoAssignmentExecuted"]; repoAssignmentOnce {
log.Trace("RepoAssignment was exec already, skipping second call ...") log.Trace("RepoAssignment was exec already, skipping second call ...")
return nil return
} }
ctx.Data["repoAssignmentExecuted"] = true ctx.Data["repoAssignmentExecuted"] = true
@ -453,7 +453,7 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
// https://github.com/golang/go/issues/19760 // https://github.com/golang/go/issues/19760
if ctx.FormString("go-get") == "1" { if ctx.FormString("go-get") == "1" {
EarlyResponseForGoGetMeta(ctx) EarlyResponseForGoGetMeta(ctx)
return nil return
} }
if redirectUserID, err := user_model.LookupUserRedirect(userName); err == nil { if redirectUserID, err := user_model.LookupUserRedirect(userName); err == nil {
@ -466,7 +466,7 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
} else { } else {
ctx.ServerError("GetUserByName", err) ctx.ServerError("GetUserByName", err)
} }
return nil return
} }
} }
ctx.Repo.Owner = owner ctx.Repo.Owner = owner
@ -490,7 +490,7 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
redirectPath += "?" + ctx.Req.URL.RawQuery redirectPath += "?" + ctx.Req.URL.RawQuery
} }
ctx.Redirect(path.Join(setting.AppSubURL, redirectPath)) ctx.Redirect(path.Join(setting.AppSubURL, redirectPath))
return nil return
} }
// Get repository. // Get repository.
@ -503,7 +503,7 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
} else if repo_model.IsErrRedirectNotExist(err) { } else if repo_model.IsErrRedirectNotExist(err) {
if ctx.FormString("go-get") == "1" { if ctx.FormString("go-get") == "1" {
EarlyResponseForGoGetMeta(ctx) EarlyResponseForGoGetMeta(ctx)
return nil return
} }
ctx.NotFound("GetRepositoryByName", nil) ctx.NotFound("GetRepositoryByName", nil)
} else { } else {
@ -512,13 +512,13 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
} else { } else {
ctx.ServerError("GetRepositoryByName", err) ctx.ServerError("GetRepositoryByName", err)
} }
return nil return
} }
repo.Owner = owner repo.Owner = owner
repoAssignment(ctx, repo) repoAssignment(ctx, repo)
if ctx.Written() { if ctx.Written() {
return nil return
} }
ctx.Repo.RepoLink = repo.Link() ctx.Repo.RepoLink = repo.Link()
@ -542,12 +542,12 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
}) })
if err != nil { if err != nil {
ctx.ServerError("GetReleaseCountByRepoID", err) ctx.ServerError("GetReleaseCountByRepoID", err)
return nil return
} }
ctx.Data["NumReleases"], err = repo_model.GetReleaseCountByRepoID(ctx, ctx.Repo.Repository.ID, repo_model.FindReleasesOptions{}) ctx.Data["NumReleases"], err = repo_model.GetReleaseCountByRepoID(ctx, ctx.Repo.Repository.ID, repo_model.FindReleasesOptions{})
if err != nil { if err != nil {
ctx.ServerError("GetReleaseCountByRepoID", err) ctx.ServerError("GetReleaseCountByRepoID", err)
return nil return
} }
ctx.Data["Title"] = owner.Name + "/" + repo.Name ctx.Data["Title"] = owner.Name + "/" + repo.Name
@ -563,14 +563,14 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
canSignedUserFork, err := repo_module.CanUserForkRepo(ctx.Doer, ctx.Repo.Repository) canSignedUserFork, err := repo_module.CanUserForkRepo(ctx.Doer, ctx.Repo.Repository)
if err != nil { if err != nil {
ctx.ServerError("CanUserForkRepo", err) ctx.ServerError("CanUserForkRepo", err)
return nil return
} }
ctx.Data["CanSignedUserFork"] = canSignedUserFork ctx.Data["CanSignedUserFork"] = canSignedUserFork
userAndOrgForks, err := repo_model.GetForksByUserAndOrgs(ctx, ctx.Doer, ctx.Repo.Repository) userAndOrgForks, err := repo_model.GetForksByUserAndOrgs(ctx, ctx.Doer, ctx.Repo.Repository)
if err != nil { if err != nil {
ctx.ServerError("GetForksByUserAndOrgs", err) ctx.ServerError("GetForksByUserAndOrgs", err)
return nil return
} }
ctx.Data["UserAndOrgForks"] = userAndOrgForks ctx.Data["UserAndOrgForks"] = userAndOrgForks
@ -604,14 +604,14 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
if repo.IsFork { if repo.IsFork {
RetrieveBaseRepo(ctx, repo) RetrieveBaseRepo(ctx, repo)
if ctx.Written() { if ctx.Written() {
return nil return
} }
} }
if repo.IsGenerated() { if repo.IsGenerated() {
RetrieveTemplateRepo(ctx, repo) RetrieveTemplateRepo(ctx, repo)
if ctx.Written() { if ctx.Written() {
return nil return
} }
} }
@ -623,7 +623,7 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
if !isHomeOrSettings { if !isHomeOrSettings {
ctx.Redirect(ctx.Repo.RepoLink) ctx.Redirect(ctx.Repo.RepoLink)
} }
return nil return
} }
gitRepo, err := git.OpenRepository(ctx, repo_model.RepoPath(userName, repoName)) gitRepo, err := git.OpenRepository(ctx, repo_model.RepoPath(userName, repoName))
@ -636,10 +636,10 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
if !isHomeOrSettings { if !isHomeOrSettings {
ctx.Redirect(ctx.Repo.RepoLink) ctx.Redirect(ctx.Repo.RepoLink)
} }
return nil return
} }
ctx.ServerError("RepoAssignment Invalid repo "+repo_model.RepoPath(userName, repoName), err) ctx.ServerError("RepoAssignment Invalid repo "+repo_model.RepoPath(userName, repoName), err)
return nil return
} }
if ctx.Repo.GitRepo != nil { if ctx.Repo.GitRepo != nil {
ctx.Repo.GitRepo.Close() ctx.Repo.GitRepo.Close()
@ -647,7 +647,7 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
ctx.Repo.GitRepo = gitRepo ctx.Repo.GitRepo = gitRepo
// We opened it, we should close it // We opened it, we should close it
cancel := func() { cancel = func() {
// If it's been set to nil then assume someone else has closed it. // If it's been set to nil then assume someone else has closed it.
if ctx.Repo.GitRepo != nil { if ctx.Repo.GitRepo != nil {
ctx.Repo.GitRepo.Close() ctx.Repo.GitRepo.Close()
@ -657,13 +657,13 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
// Stop at this point when the repo is empty. // Stop at this point when the repo is empty.
if ctx.Repo.Repository.IsEmpty { if ctx.Repo.Repository.IsEmpty {
ctx.Data["BranchName"] = ctx.Repo.Repository.DefaultBranch ctx.Data["BranchName"] = ctx.Repo.Repository.DefaultBranch
return cancel return
} }
tags, err := repo_model.GetTagNamesByRepoID(ctx, ctx.Repo.Repository.ID) tags, err := repo_model.GetTagNamesByRepoID(ctx, ctx.Repo.Repository.ID)
if err != nil { if err != nil {
ctx.ServerError("GetTagNamesByRepoID", err) ctx.ServerError("GetTagNamesByRepoID", err)
return cancel return
} }
ctx.Data["Tags"] = tags ctx.Data["Tags"] = tags
@ -677,7 +677,7 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
branchesTotal, err := git_model.CountBranches(ctx, branchOpts) branchesTotal, err := git_model.CountBranches(ctx, branchOpts)
if err != nil { if err != nil {
ctx.ServerError("CountBranches", err) ctx.ServerError("CountBranches", err)
return cancel return
} }
// non empty repo should have at least 1 branch, so this repository's branches haven't been synced yet // non empty repo should have at least 1 branch, so this repository's branches haven't been synced yet
@ -685,7 +685,7 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
branchesTotal, err = repo_module.SyncRepoBranches(ctx, ctx.Repo.Repository.ID, 0) branchesTotal, err = repo_module.SyncRepoBranches(ctx, ctx.Repo.Repository.ID, 0)
if err != nil { if err != nil {
ctx.ServerError("SyncRepoBranches", err) ctx.ServerError("SyncRepoBranches", err)
return cancel return
} }
} }
@ -694,7 +694,7 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
brs, err := git_model.FindBranchNames(ctx, branchOpts) brs, err := git_model.FindBranchNames(ctx, branchOpts)
if err != nil { if err != nil {
ctx.ServerError("GetBranches", err) ctx.ServerError("GetBranches", err)
return cancel return
} }
// always put default branch on the top // always put default branch on the top
ctx.Data["Branches"] = append(branchOpts.ExcludeBranchNames, brs...) ctx.Data["Branches"] = append(branchOpts.ExcludeBranchNames, brs...)
@ -741,12 +741,12 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
repoTransfer, err := models.GetPendingRepositoryTransfer(ctx, ctx.Repo.Repository) repoTransfer, err := models.GetPendingRepositoryTransfer(ctx, ctx.Repo.Repository)
if err != nil { if err != nil {
ctx.ServerError("GetPendingRepositoryTransfer", err) ctx.ServerError("GetPendingRepositoryTransfer", err)
return cancel return
} }
if err := repoTransfer.LoadAttributes(ctx); err != nil { if err := repoTransfer.LoadAttributes(ctx); err != nil {
ctx.ServerError("LoadRecipient", err) ctx.ServerError("LoadRecipient", err)
return cancel return
} }
ctx.Data["RepoTransfer"] = repoTransfer ctx.Data["RepoTransfer"] = repoTransfer
@ -894,7 +894,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
ctx.Repo.IsViewBranch = true ctx.Repo.IsViewBranch = true
ctx.Repo.BranchName = ctx.Repo.Repository.DefaultBranch ctx.Repo.BranchName = ctx.Repo.Repository.DefaultBranch
ctx.Data["TreePath"] = "" ctx.Data["TreePath"] = ""
return nil return
} }
var ( var (
@ -907,7 +907,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
ctx.Repo.GitRepo, err = git.OpenRepository(ctx, repoPath) ctx.Repo.GitRepo, err = git.OpenRepository(ctx, repoPath)
if err != nil { if err != nil {
ctx.ServerError("RepoRef Invalid repo "+repoPath, err) ctx.ServerError("RepoRef Invalid repo "+repoPath, err)
return nil return
} }
// We opened it, we should close it // We opened it, we should close it
cancel = func() { cancel = func() {
@ -944,7 +944,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
ctx.Repo.Repository.MarkAsBrokenEmpty() ctx.Repo.Repository.MarkAsBrokenEmpty()
} else { } else {
ctx.ServerError("GetBranchCommit", err) ctx.ServerError("GetBranchCommit", err)
return cancel return
} }
ctx.Repo.IsViewBranch = true ctx.Repo.IsViewBranch = true
} else { } else {
@ -956,7 +956,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
ctx.Flash.Info(ctx.Tr("repo.branch.renamed", refName, renamedBranchName)) ctx.Flash.Info(ctx.Tr("repo.branch.renamed", refName, renamedBranchName))
link := setting.AppSubURL + strings.Replace(ctx.Req.URL.EscapedPath(), util.PathEscapeSegments(refName), util.PathEscapeSegments(renamedBranchName), 1) link := setting.AppSubURL + strings.Replace(ctx.Req.URL.EscapedPath(), util.PathEscapeSegments(refName), util.PathEscapeSegments(renamedBranchName), 1)
ctx.Redirect(link) ctx.Redirect(link)
return cancel return
} }
if refType.RefTypeIncludesBranches() && ctx.Repo.GitRepo.IsBranchExist(refName) { if refType.RefTypeIncludesBranches() && ctx.Repo.GitRepo.IsBranchExist(refName) {
@ -966,7 +966,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(refName) ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(refName)
if err != nil { if err != nil {
ctx.ServerError("GetBranchCommit", err) ctx.ServerError("GetBranchCommit", err)
return cancel return
} }
ctx.Repo.CommitID = ctx.Repo.Commit.ID.String() ctx.Repo.CommitID = ctx.Repo.Commit.ID.String()
@ -978,10 +978,10 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
if err != nil { if err != nil {
if git.IsErrNotExist(err) { if git.IsErrNotExist(err) {
ctx.NotFound("GetTagCommit", err) ctx.NotFound("GetTagCommit", err)
return cancel return
} }
ctx.ServerError("GetTagCommit", err) ctx.ServerError("GetTagCommit", err)
return cancel return
} }
ctx.Repo.CommitID = ctx.Repo.Commit.ID.String() ctx.Repo.CommitID = ctx.Repo.Commit.ID.String()
} else if len(refName) >= 7 && len(refName) <= git.SHAFullLength { } else if len(refName) >= 7 && len(refName) <= git.SHAFullLength {
@ -991,7 +991,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetCommit(refName) ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetCommit(refName)
if err != nil { if err != nil {
ctx.NotFound("GetCommit", err) ctx.NotFound("GetCommit", err)
return cancel return
} }
// If short commit ID add canonical link header // If short commit ID add canonical link header
if len(refName) < git.SHAFullLength { if len(refName) < git.SHAFullLength {
@ -1000,10 +1000,10 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
} }
} else { } else {
if len(ignoreNotExistErr) > 0 && ignoreNotExistErr[0] { if len(ignoreNotExistErr) > 0 && ignoreNotExistErr[0] {
return cancel return
} }
ctx.NotFound("RepoRef invalid repo", fmt.Errorf("branch or tag not exist: %s", refName)) ctx.NotFound("RepoRef invalid repo", fmt.Errorf("branch or tag not exist: %s", refName))
return cancel return
} }
if refType == RepoRefLegacy { if refType == RepoRefLegacy {
@ -1015,7 +1015,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
util.PathEscapeSegments(prefix), util.PathEscapeSegments(prefix),
ctx.Repo.BranchNameSubURL(), ctx.Repo.BranchNameSubURL(),
util.PathEscapeSegments(ctx.Repo.TreePath))) util.PathEscapeSegments(ctx.Repo.TreePath)))
return cancel return
} }
} }
@ -1033,7 +1033,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
ctx.Repo.CommitsCount, err = ctx.Repo.GetCommitsCount() ctx.Repo.CommitsCount, err = ctx.Repo.GetCommitsCount()
if err != nil { if err != nil {
ctx.ServerError("GetCommitsCount", err) ctx.ServerError("GetCommitsCount", err)
return cancel return
} }
ctx.Data["CommitsCount"] = ctx.Repo.CommitsCount ctx.Data["CommitsCount"] = ctx.Repo.CommitsCount
ctx.Repo.GitRepo.LastCommitCache = git.NewLastCommitCache(ctx.Repo.CommitsCount, ctx.Repo.Repository.FullName(), ctx.Repo.GitRepo, cache.GetCache()) ctx.Repo.GitRepo.LastCommitCache = git.NewLastCommitCache(ctx.Repo.CommitsCount, ctx.Repo.Repository.FullName(), ctx.Repo.GitRepo, cache.GetCache())

View File

@ -6,7 +6,6 @@ package doctor
import ( import (
"bytes" "bytes"
"context" "context"
"errors"
"fmt" "fmt"
"code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/db"
@ -41,12 +40,12 @@ func parseBool16961(bs []byte) (bool, error) {
func fixUnitConfig16961(bs []byte, cfg *repo_model.UnitConfig) (fixed bool, err error) { func fixUnitConfig16961(bs []byte, cfg *repo_model.UnitConfig) (fixed bool, err error) {
err = json.UnmarshalHandleDoubleEncode(bs, &cfg) err = json.UnmarshalHandleDoubleEncode(bs, &cfg)
if err == nil { if err == nil {
return false, nil return
} }
// Handle #16961 // Handle #16961
if string(bs) != "&{}" && len(bs) != 0 { if string(bs) != "&{}" && len(bs) != 0 {
return false, err return
} }
return true, nil return true, nil
@ -55,14 +54,14 @@ func fixUnitConfig16961(bs []byte, cfg *repo_model.UnitConfig) (fixed bool, err
func fixExternalWikiConfig16961(bs []byte, cfg *repo_model.ExternalWikiConfig) (fixed bool, err error) { func fixExternalWikiConfig16961(bs []byte, cfg *repo_model.ExternalWikiConfig) (fixed bool, err error) {
err = json.UnmarshalHandleDoubleEncode(bs, &cfg) err = json.UnmarshalHandleDoubleEncode(bs, &cfg)
if err == nil { if err == nil {
return false, nil return
} }
if len(bs) < 3 { if len(bs) < 3 {
return false, err return
} }
if bs[0] != '&' || bs[1] != '{' || bs[len(bs)-1] != '}' { if bs[0] != '&' || bs[1] != '{' || bs[len(bs)-1] != '}' {
return false, err return
} }
cfg.ExternalWikiURL = string(bs[2 : len(bs)-1]) cfg.ExternalWikiURL = string(bs[2 : len(bs)-1])
return true, nil return true, nil
@ -71,20 +70,20 @@ func fixExternalWikiConfig16961(bs []byte, cfg *repo_model.ExternalWikiConfig) (
func fixExternalTrackerConfig16961(bs []byte, cfg *repo_model.ExternalTrackerConfig) (fixed bool, err error) { func fixExternalTrackerConfig16961(bs []byte, cfg *repo_model.ExternalTrackerConfig) (fixed bool, err error) {
err = json.UnmarshalHandleDoubleEncode(bs, &cfg) err = json.UnmarshalHandleDoubleEncode(bs, &cfg)
if err == nil { if err == nil {
return false, nil return
} }
// Handle #16961 // Handle #16961
if len(bs) < 3 { if len(bs) < 3 {
return false, err return
} }
if bs[0] != '&' || bs[1] != '{' || bs[len(bs)-1] != '}' { if bs[0] != '&' || bs[1] != '{' || bs[len(bs)-1] != '}' {
return false, err return
} }
parts := bytes.Split(bs[2:len(bs)-1], []byte{' '}) parts := bytes.Split(bs[2:len(bs)-1], []byte{' '})
if len(parts) != 3 { if len(parts) != 3 {
return false, err return
} }
cfg.ExternalTrackerURL = string(bytes.Join(parts[:len(parts)-2], []byte{' '})) cfg.ExternalTrackerURL = string(bytes.Join(parts[:len(parts)-2], []byte{' '}))
@ -96,16 +95,16 @@ func fixExternalTrackerConfig16961(bs []byte, cfg *repo_model.ExternalTrackerCon
func fixPullRequestsConfig16961(bs []byte, cfg *repo_model.PullRequestsConfig) (fixed bool, err error) { func fixPullRequestsConfig16961(bs []byte, cfg *repo_model.PullRequestsConfig) (fixed bool, err error) {
err = json.UnmarshalHandleDoubleEncode(bs, &cfg) err = json.UnmarshalHandleDoubleEncode(bs, &cfg)
if err == nil { if err == nil {
return false, nil return
} }
// Handle #16961 // Handle #16961
if len(bs) < 3 { if len(bs) < 3 {
return false, err return
} }
if bs[0] != '&' || bs[1] != '{' || bs[len(bs)-1] != '}' { if bs[0] != '&' || bs[1] != '{' || bs[len(bs)-1] != '}' {
return false, err return
} }
// PullRequestsConfig was the following in 1.14 // PullRequestsConfig was the following in 1.14
@ -124,37 +123,37 @@ func fixPullRequestsConfig16961(bs []byte, cfg *repo_model.PullRequestsConfig) (
// DefaultMergeStyle MergeStyle // DefaultMergeStyle MergeStyle
parts := bytes.Split(bs[2:len(bs)-1], []byte{' '}) parts := bytes.Split(bs[2:len(bs)-1], []byte{' '})
if len(parts) < 7 { if len(parts) < 7 {
return false, err return
} }
var parseErr error var parseErr error
cfg.IgnoreWhitespaceConflicts, parseErr = parseBool16961(parts[0]) cfg.IgnoreWhitespaceConflicts, parseErr = parseBool16961(parts[0])
if parseErr != nil { if parseErr != nil {
return false, errors.Join(err, parseErr) return
} }
cfg.AllowMerge, parseErr = parseBool16961(parts[1]) cfg.AllowMerge, parseErr = parseBool16961(parts[1])
if parseErr != nil { if parseErr != nil {
return false, errors.Join(err, parseErr) return
} }
cfg.AllowRebase, parseErr = parseBool16961(parts[2]) cfg.AllowRebase, parseErr = parseBool16961(parts[2])
if parseErr != nil { if parseErr != nil {
return false, errors.Join(err, parseErr) return
} }
cfg.AllowRebaseMerge, parseErr = parseBool16961(parts[3]) cfg.AllowRebaseMerge, parseErr = parseBool16961(parts[3])
if parseErr != nil { if parseErr != nil {
return false, errors.Join(err, parseErr) return
} }
cfg.AllowSquash, parseErr = parseBool16961(parts[4]) cfg.AllowSquash, parseErr = parseBool16961(parts[4])
if parseErr != nil { if parseErr != nil {
return false, errors.Join(err, parseErr) return
} }
cfg.AllowManualMerge, parseErr = parseBool16961(parts[5]) cfg.AllowManualMerge, parseErr = parseBool16961(parts[5])
if parseErr != nil { if parseErr != nil {
return false, errors.Join(err, parseErr) return
} }
cfg.AutodetectManualMerge, parseErr = parseBool16961(parts[6]) cfg.AutodetectManualMerge, parseErr = parseBool16961(parts[6])
if parseErr != nil { if parseErr != nil {
return false, errors.Join(err, parseErr) return
} }
// 1.14 unit // 1.14 unit
@ -163,12 +162,12 @@ func fixPullRequestsConfig16961(bs []byte, cfg *repo_model.PullRequestsConfig) (
} }
if len(parts) < 9 { if len(parts) < 9 {
return false, err return
} }
cfg.DefaultDeleteBranchAfterMerge, parseErr = parseBool16961(parts[7]) cfg.DefaultDeleteBranchAfterMerge, parseErr = parseBool16961(parts[7])
if parseErr != nil { if parseErr != nil {
return false, errors.Join(err, parseErr) return
} }
cfg.DefaultMergeStyle = repo_model.MergeStyle(string(bytes.Join(parts[8:], []byte{' '}))) cfg.DefaultMergeStyle = repo_model.MergeStyle(string(bytes.Join(parts[8:], []byte{' '})))
@ -178,34 +177,34 @@ func fixPullRequestsConfig16961(bs []byte, cfg *repo_model.PullRequestsConfig) (
func fixIssuesConfig16961(bs []byte, cfg *repo_model.IssuesConfig) (fixed bool, err error) { func fixIssuesConfig16961(bs []byte, cfg *repo_model.IssuesConfig) (fixed bool, err error) {
err = json.UnmarshalHandleDoubleEncode(bs, &cfg) err = json.UnmarshalHandleDoubleEncode(bs, &cfg)
if err == nil { if err == nil {
return false, nil return
} }
// Handle #16961 // Handle #16961
if len(bs) < 3 { if len(bs) < 3 {
return false, err return
} }
if bs[0] != '&' || bs[1] != '{' || bs[len(bs)-1] != '}' { if bs[0] != '&' || bs[1] != '{' || bs[len(bs)-1] != '}' {
return false, err return
} }
parts := bytes.Split(bs[2:len(bs)-1], []byte{' '}) parts := bytes.Split(bs[2:len(bs)-1], []byte{' '})
if len(parts) != 3 { if len(parts) != 3 {
return false, err return
} }
var parseErr error var parseErr error
cfg.EnableTimetracker, parseErr = parseBool16961(parts[0]) cfg.EnableTimetracker, parseErr = parseBool16961(parts[0])
if parseErr != nil { if parseErr != nil {
return false, errors.Join(err, parseErr) return
} }
cfg.AllowOnlyContributorsToTrackTime, parseErr = parseBool16961(parts[1]) cfg.AllowOnlyContributorsToTrackTime, parseErr = parseBool16961(parts[1])
if parseErr != nil { if parseErr != nil {
return false, errors.Join(err, parseErr) return
} }
cfg.EnableDependencies, parseErr = parseBool16961(parts[2]) cfg.EnableDependencies, parseErr = parseBool16961(parts[2])
if parseErr != nil { if parseErr != nil {
return false, errors.Join(err, parseErr) return
} }
return true, nil return true, nil
} }

View File

@ -15,7 +15,7 @@ import (
func wrapNewlines(w io.Writer, prefix, value []byte) (sum int64, err error) { func wrapNewlines(w io.Writer, prefix, value []byte) (sum int64, err error) {
if len(value) == 0 { if len(value) == 0 {
return 0, nil return
} }
var n int var n int
last := 0 last := 0
@ -23,24 +23,24 @@ func wrapNewlines(w io.Writer, prefix, value []byte) (sum int64, err error) {
n, err = w.Write(prefix) n, err = w.Write(prefix)
sum += int64(n) sum += int64(n)
if err != nil { if err != nil {
return sum, err return
} }
n, err = w.Write(value[last : last+j+1]) n, err = w.Write(value[last : last+j+1])
sum += int64(n) sum += int64(n)
if err != nil { if err != nil {
return sum, err return
} }
last += j + 1 last += j + 1
} }
n, err = w.Write(prefix) n, err = w.Write(prefix)
sum += int64(n) sum += int64(n)
if err != nil { if err != nil {
return sum, err return
} }
n, err = w.Write(value[last:]) n, err = w.Write(value[last:])
sum += int64(n) sum += int64(n)
if err != nil { if err != nil {
return sum, err return
} }
n, err = w.Write([]byte("\n")) n, err = w.Write([]byte("\n"))
sum += int64(n) sum += int64(n)

View File

@ -70,11 +70,11 @@ func checkIfNoneMatchIsValid(req *http.Request, etag string) bool {
// HandleGenericETagTimeCache handles ETag-based caching with Last-Modified caching for a HTTP request. // HandleGenericETagTimeCache handles ETag-based caching with Last-Modified caching for a HTTP request.
// It returns true if the request was handled. // It returns true if the request was handled.
func HandleGenericETagTimeCache(req *http.Request, w http.ResponseWriter, etag string, lastModified *time.Time) (handled bool) { func HandleGenericETagTimeCache(req *http.Request, w http.ResponseWriter, etag string, lastModified time.Time) (handled bool) {
if len(etag) > 0 { if len(etag) > 0 {
w.Header().Set("Etag", etag) w.Header().Set("Etag", etag)
} }
if lastModified != nil && !lastModified.IsZero() { if !lastModified.IsZero() {
w.Header().Set("Last-Modified", lastModified.Format(http.TimeFormat)) w.Header().Set("Last-Modified", lastModified.Format(http.TimeFormat))
} }
@ -84,7 +84,7 @@ func HandleGenericETagTimeCache(req *http.Request, w http.ResponseWriter, etag s
return true return true
} }
} }
if lastModified != nil && !lastModified.IsZero() { if !lastModified.IsZero() {
ifModifiedSince := req.Header.Get("If-Modified-Since") ifModifiedSince := req.Header.Get("If-Modified-Since")
if ifModifiedSince != "" { if ifModifiedSince != "" {
t, err := time.Parse(http.TimeFormat, ifModifiedSince) t, err := time.Parse(http.TimeFormat, ifModifiedSince)

View File

@ -206,7 +206,7 @@ func ServeContentByReader(r *http.Request, w http.ResponseWriter, filePath strin
_, _ = io.CopyN(w, reader, partialLength) // just like http.ServeContent, not necessary to handle the error _, _ = io.CopyN(w, reader, partialLength) // just like http.ServeContent, not necessary to handle the error
} }
func ServeContentByReadSeeker(r *http.Request, w http.ResponseWriter, filePath string, modTime *time.Time, reader io.ReadSeeker) { func ServeContentByReadSeeker(r *http.Request, w http.ResponseWriter, filePath string, modTime time.Time, reader io.ReadSeeker) {
buf := make([]byte, mimeDetectionBufferLen) buf := make([]byte, mimeDetectionBufferLen)
n, err := util.ReadAtMost(reader, buf) n, err := util.ReadAtMost(reader, buf)
if err != nil { if err != nil {
@ -221,8 +221,5 @@ func ServeContentByReadSeeker(r *http.Request, w http.ResponseWriter, filePath s
buf = buf[:n] buf = buf[:n]
} }
setServeHeadersByFile(r, w, filePath, buf) setServeHeadersByFile(r, w, filePath, buf)
if modTime == nil { http.ServeContent(w, r, path.Base(filePath), modTime, reader)
modTime = &time.Time{}
}
http.ServeContent(w, r, path.Base(filePath), *modTime, reader)
} }

View File

@ -11,6 +11,7 @@ import (
"os" "os"
"strings" "strings"
"testing" "testing"
"time"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
@ -77,7 +78,7 @@ func TestServeContentByReadSeeker(t *testing.T) {
defer seekReader.Close() defer seekReader.Close()
w := httptest.NewRecorder() w := httptest.NewRecorder()
ServeContentByReadSeeker(r, w, "test", nil, seekReader) ServeContentByReadSeeker(r, w, "test", time.Time{}, seekReader)
assert.Equal(t, expectedStatusCode, w.Code) assert.Equal(t, expectedStatusCode, w.Code)
if expectedStatusCode == http.StatusPartialContent || expectedStatusCode == http.StatusOK { if expectedStatusCode == http.StatusPartialContent || expectedStatusCode == http.StatusOK {
assert.Equal(t, fmt.Sprint(len(expectedContent)), w.Header().Get("Content-Length")) assert.Equal(t, fmt.Sprint(len(expectedContent)), w.Header().Get("Content-Length"))

View File

@ -138,7 +138,7 @@ func (b *Indexer) Delete(_ context.Context, ids ...int64) error {
// Search searches for issues by given conditions. // Search searches for issues by given conditions.
// Returns the matching issue IDs // Returns the matching issue IDs
func (b *Indexer) Search(ctx context.Context, keyword string, repoIDs []int64, limit, start int, state string) (*internal.SearchResult, error) { func (b *Indexer) Search(ctx context.Context, keyword string, repoIDs []int64, limit, start int) (*internal.SearchResult, error) {
var repoQueriesP []*query.NumericRangeQuery var repoQueriesP []*query.NumericRangeQuery
for _, repoID := range repoIDs { for _, repoID := range repoIDs {
repoQueriesP = append(repoQueriesP, numericEqualityQuery(repoID, "repo_id")) repoQueriesP = append(repoQueriesP, numericEqualityQuery(repoID, "repo_id"))

View File

@ -77,7 +77,7 @@ func TestBleveIndexAndSearch(t *testing.T) {
} }
for _, kw := range keywords { for _, kw := range keywords {
res, err := indexer.Search(context.TODO(), kw.Keyword, []int64{2}, 10, 0, "") res, err := indexer.Search(context.TODO(), kw.Keyword, []int64{2}, 10, 0)
assert.NoError(t, err) assert.NoError(t, err)
ids := make([]int64, 0, len(res.Hits)) ids := make([]int64, 0, len(res.Hits))

View File

@ -36,7 +36,7 @@ func (i *Indexer) Delete(_ context.Context, _ ...int64) error {
} }
// Search searches for issues // Search searches for issues
func (i *Indexer) Search(ctx context.Context, kw string, repoIDs []int64, limit, start int, state string) (*internal.SearchResult, error) { func (i *Indexer) Search(ctx context.Context, kw string, repoIDs []int64, limit, start int) (*internal.SearchResult, error) {
total, ids, err := issues_model.SearchIssueIDsByKeyword(ctx, kw, repoIDs, limit, start) total, ids, err := issues_model.SearchIssueIDsByKeyword(ctx, kw, repoIDs, limit, start)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -140,7 +140,7 @@ func (b *Indexer) Delete(ctx context.Context, ids ...int64) error {
// Search searches for issues by given conditions. // Search searches for issues by given conditions.
// Returns the matching issue IDs // Returns the matching issue IDs
func (b *Indexer) Search(ctx context.Context, keyword string, repoIDs []int64, limit, start int, state string) (*internal.SearchResult, error) { func (b *Indexer) Search(ctx context.Context, keyword string, repoIDs []int64, limit, start int) (*internal.SearchResult, error) {
kwQuery := elastic.NewMultiMatchQuery(keyword, "title", "content", "comments") kwQuery := elastic.NewMultiMatchQuery(keyword, "title", "content", "comments")
query := elastic.NewBoolQuery() query := elastic.NewBoolQuery()
query = query.Must(kwQuery) query = query.Must(kwQuery)

View File

@ -242,15 +242,9 @@ func UpdateIssueIndexer(issue *issues_model.Issue) {
comments = append(comments, comment.Content) comments = append(comments, comment.Content)
} }
} }
issueType := "issue"
if issue.IsPull {
issueType = "pull"
}
indexerData := &internal.IndexerData{ indexerData := &internal.IndexerData{
ID: issue.ID, ID: issue.ID,
RepoID: issue.RepoID, RepoID: issue.RepoID,
State: string(issue.State()),
IssueType: issueType,
Title: issue.Title, Title: issue.Title,
Content: issue.Content, Content: issue.Content,
Comments: comments, Comments: comments,
@ -284,10 +278,10 @@ func DeleteRepoIssueIndexer(ctx context.Context, repo *repo_model.Repository) {
// SearchIssuesByKeyword search issue ids by keywords and repo id // SearchIssuesByKeyword search issue ids by keywords and repo id
// WARNNING: You have to ensure user have permission to visit repoIDs' issues // WARNNING: You have to ensure user have permission to visit repoIDs' issues
func SearchIssuesByKeyword(ctx context.Context, repoIDs []int64, keyword, state string) ([]int64, error) { func SearchIssuesByKeyword(ctx context.Context, repoIDs []int64, keyword string) ([]int64, error) {
var issueIDs []int64 var issueIDs []int64
indexer := *globalIndexer.Load() indexer := *globalIndexer.Load()
res, err := indexer.Search(ctx, keyword, repoIDs, 50, 0, state) res, err := indexer.Search(ctx, keyword, repoIDs, 50, 0)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -50,19 +50,19 @@ func TestBleveSearchIssues(t *testing.T) {
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)
ids, err := SearchIssuesByKeyword(context.TODO(), []int64{1}, "issue2", "") ids, err := SearchIssuesByKeyword(context.TODO(), []int64{1}, "issue2")
assert.NoError(t, err) assert.NoError(t, err)
assert.EqualValues(t, []int64{2}, ids) assert.EqualValues(t, []int64{2}, ids)
ids, err = SearchIssuesByKeyword(context.TODO(), []int64{1}, "first", "") ids, err = SearchIssuesByKeyword(context.TODO(), []int64{1}, "first")
assert.NoError(t, err) assert.NoError(t, err)
assert.EqualValues(t, []int64{1}, ids) assert.EqualValues(t, []int64{1}, ids)
ids, err = SearchIssuesByKeyword(context.TODO(), []int64{1}, "for", "") ids, err = SearchIssuesByKeyword(context.TODO(), []int64{1}, "for")
assert.NoError(t, err) assert.NoError(t, err)
assert.ElementsMatch(t, []int64{1, 2, 3, 5, 11}, ids) assert.ElementsMatch(t, []int64{1, 2, 3, 5, 11}, ids)
ids, err = SearchIssuesByKeyword(context.TODO(), []int64{1}, "good", "") ids, err = SearchIssuesByKeyword(context.TODO(), []int64{1}, "good")
assert.NoError(t, err) assert.NoError(t, err)
assert.EqualValues(t, []int64{1}, ids) assert.EqualValues(t, []int64{1}, ids)
} }
@ -73,19 +73,19 @@ func TestDBSearchIssues(t *testing.T) {
setting.Indexer.IssueType = "db" setting.Indexer.IssueType = "db"
InitIssueIndexer(true) InitIssueIndexer(true)
ids, err := SearchIssuesByKeyword(context.TODO(), []int64{1}, "issue2", "") ids, err := SearchIssuesByKeyword(context.TODO(), []int64{1}, "issue2")
assert.NoError(t, err) assert.NoError(t, err)
assert.EqualValues(t, []int64{2}, ids) assert.EqualValues(t, []int64{2}, ids)
ids, err = SearchIssuesByKeyword(context.TODO(), []int64{1}, "first", "") ids, err = SearchIssuesByKeyword(context.TODO(), []int64{1}, "first")
assert.NoError(t, err) assert.NoError(t, err)
assert.EqualValues(t, []int64{1}, ids) assert.EqualValues(t, []int64{1}, ids)
ids, err = SearchIssuesByKeyword(context.TODO(), []int64{1}, "for", "") ids, err = SearchIssuesByKeyword(context.TODO(), []int64{1}, "for")
assert.NoError(t, err) assert.NoError(t, err)
assert.ElementsMatch(t, []int64{1, 2, 3, 5, 11}, ids) assert.ElementsMatch(t, []int64{1, 2, 3, 5, 11}, ids)
ids, err = SearchIssuesByKeyword(context.TODO(), []int64{1}, "good", "") ids, err = SearchIssuesByKeyword(context.TODO(), []int64{1}, "good")
assert.NoError(t, err) assert.NoError(t, err)
assert.EqualValues(t, []int64{1}, ids) assert.EqualValues(t, []int64{1}, ids)
} }

View File

@ -15,7 +15,7 @@ type Indexer interface {
internal.Indexer internal.Indexer
Index(ctx context.Context, issue []*IndexerData) error Index(ctx context.Context, issue []*IndexerData) error
Delete(ctx context.Context, ids ...int64) error Delete(ctx context.Context, ids ...int64) error
Search(ctx context.Context, kw string, repoIDs []int64, limit, start int, state string) (*SearchResult, error) Search(ctx context.Context, kw string, repoIDs []int64, limit, start int) (*SearchResult, error)
} }
// NewDummyIndexer returns a dummy indexer // NewDummyIndexer returns a dummy indexer
@ -37,6 +37,6 @@ func (d *dummyIndexer) Delete(ctx context.Context, ids ...int64) error {
return fmt.Errorf("indexer is not ready") return fmt.Errorf("indexer is not ready")
} }
func (d *dummyIndexer) Search(ctx context.Context, kw string, repoIDs []int64, limit, start int, state string) (*SearchResult, error) { func (d *dummyIndexer) Search(ctx context.Context, kw string, repoIDs []int64, limit, start int) (*SearchResult, error) {
return nil, fmt.Errorf("indexer is not ready") return nil, fmt.Errorf("indexer is not ready")
} }

View File

@ -7,8 +7,6 @@ package internal
type IndexerData struct { type IndexerData struct {
ID int64 `json:"id"` ID int64 `json:"id"`
RepoID int64 `json:"repo_id"` RepoID int64 `json:"repo_id"`
State string `json:"state"` // open, closed, all
IssueType string `json:"type"` // issue or pull
Title string `json:"title"` Title string `json:"title"`
Content string `json:"content"` Content string `json:"content"`
Comments []string `json:"comments"` Comments []string `json:"comments"`

View File

@ -16,7 +16,7 @@ import (
) )
const ( const (
issueIndexerLatestVersion = 1 issueIndexerLatestVersion = 0
) )
var _ internal.Indexer = &Indexer{} var _ internal.Indexer = &Indexer{}
@ -70,19 +70,12 @@ func (b *Indexer) Delete(_ context.Context, ids ...int64) error {
// Search searches for issues by given conditions. // Search searches for issues by given conditions.
// Returns the matching issue IDs // Returns the matching issue IDs
func (b *Indexer) Search(ctx context.Context, keyword string, repoIDs []int64, limit, start int, state string) (*internal.SearchResult, error) { func (b *Indexer) Search(ctx context.Context, keyword string, repoIDs []int64, limit, start int) (*internal.SearchResult, error) {
repoFilters := make([]string, 0, len(repoIDs)) repoFilters := make([]string, 0, len(repoIDs))
for _, repoID := range repoIDs { for _, repoID := range repoIDs {
repoFilters = append(repoFilters, "repo_id = "+strconv.FormatInt(repoID, 10)) repoFilters = append(repoFilters, "repo_id = "+strconv.FormatInt(repoID, 10))
} }
filter := strings.Join(repoFilters, " OR ") filter := strings.Join(repoFilters, " OR ")
if state == "open" || state == "closed" {
if filter != "" {
filter = "(" + filter + ") AND state = " + state
} else {
filter = "state = " + state
}
}
searchRes, err := b.inner.Client.Index(b.inner.VersionedIndexName()).Search(keyword, &meilisearch.SearchRequest{ searchRes, err := b.inner.Client.Index(b.inner.VersionedIndexName()).Search(keyword, &meilisearch.SearchRequest{
Filter: filter, Filter: filter,
Limit: int64(limit), Limit: int64(limit),

View File

@ -211,7 +211,7 @@ func (pm *Manager) nextPID() (start time.Time, pid IDType) {
pid = IDType(strconv.FormatInt(start.Unix(), 16)) pid = IDType(strconv.FormatInt(start.Unix(), 16))
if pm.next == 1 { if pm.next == 1 {
return start, pid return
} }
pid = IDType(string(pid) + "-" + strconv.FormatInt(pm.next, 10)) pid = IDType(string(pid) + "-" + strconv.FormatInt(pm.next, 10))
return start, pid return start, pid

View File

@ -256,8 +256,3 @@ func ToFloat64(number any) (float64, error) {
} }
return value, nil return value, nil
} }
// ToPointer returns the pointer of a copy of any given value
func ToPointer[T any](val T) *T {
return &val
}

View File

@ -224,12 +224,3 @@ func TestToTitleCase(t *testing.T) {
assert.Equal(t, ToTitleCase(`foo bar baz`), `Foo Bar Baz`) assert.Equal(t, ToTitleCase(`foo bar baz`), `Foo Bar Baz`)
assert.Equal(t, ToTitleCase(`FOO BAR BAZ`), `Foo Bar Baz`) assert.Equal(t, ToTitleCase(`FOO BAR BAZ`), `Foo Bar Baz`)
} }
func TestToPointer(t *testing.T) {
assert.Equal(t, "abc", *ToPointer("abc"))
assert.Equal(t, 123, *ToPointer(123))
abc := "abc"
assert.False(t, &abc == ToPointer(abc))
val123 := 123
assert.False(t, &val123 == ToPointer(val123))
}

View File

@ -1767,8 +1767,6 @@ pulls.auto_merge_canceled_schedule_comment = `canceled auto merging this pull re
pulls.delete.title = Delete this pull request? pulls.delete.title = Delete this pull request?
pulls.delete.text = Do you really want to delete this pull request? (This will permanently remove all content. Consider closing it instead, if you intend to keep it archived) pulls.delete.text = Do you really want to delete this pull request? (This will permanently remove all content. Consider closing it instead, if you intend to keep it archived)
pulls.recently_pushed_new_branches = You pushed on branch <strong>%[1]s</strong> %[2]s
milestones.new = New Milestone milestones.new = New Milestone
milestones.closed = Closed %s milestones.closed = Closed %s
milestones.update_ago = Updated %s milestones.update_ago = Updated %s
@ -3234,7 +3232,6 @@ desc = Manage repository packages.
empty = There are no packages yet. empty = There are no packages yet.
empty.documentation = For more information on the package registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>. empty.documentation = For more information on the package registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
empty.repo = Did you upload a package, but it's not shown here? Go to <a href="%[1]s">package settings</a> and link it to this repo. empty.repo = Did you upload a package, but it's not shown here? Go to <a href="%[1]s">package settings</a> and link it to this repo.
registry.documentation = For more information on the %s registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
filter.type = Type filter.type = Type
filter.type.all = All filter.type.all = All
filter.no_result = Your filter produced no results. filter.no_result = Your filter produced no results.
@ -3262,31 +3259,38 @@ alpine.registry = Setup this registry by adding the url in your <code>/etc/apk/r
alpine.registry.key = Download the registry public RSA key into the <code>/etc/apk/keys/</code> folder to verify the index signature: alpine.registry.key = Download the registry public RSA key into the <code>/etc/apk/keys/</code> folder to verify the index signature:
alpine.registry.info = Choose $branch and $repository from the list below. alpine.registry.info = Choose $branch and $repository from the list below.
alpine.install = To install the package, run the following command: alpine.install = To install the package, run the following command:
alpine.documentation = For more information on the Alpine registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
alpine.repository = Repository Info alpine.repository = Repository Info
alpine.repository.branches = Branches alpine.repository.branches = Branches
alpine.repository.repositories = Repositories alpine.repository.repositories = Repositories
alpine.repository.architectures = Architectures alpine.repository.architectures = Architectures
cargo.registry = Setup this registry in the Cargo configuration file (for example <code>~/.cargo/config.toml</code>): cargo.registry = Setup this registry in the Cargo configuration file (for example <code>~/.cargo/config.toml</code>):
cargo.install = To install the package using Cargo, run the following command: cargo.install = To install the package using Cargo, run the following command:
cargo.documentation = For more information on the Cargo registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
cargo.details.repository_site = Repository Site cargo.details.repository_site = Repository Site
cargo.details.documentation_site = Documentation Site cargo.details.documentation_site = Documentation Site
chef.registry = Setup this registry in your <code>~/.chef/config.rb</code> file: chef.registry = Setup this registry in your <code>~/.chef/config.rb</code> file:
chef.install = To install the package, run the following command: chef.install = To install the package, run the following command:
chef.documentation = For more information on the Chef registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
composer.registry = Setup this registry in your <code>~/.composer/config.json</code> file: composer.registry = Setup this registry in your <code>~/.composer/config.json</code> file:
composer.install = To install the package using Composer, run the following command: composer.install = To install the package using Composer, run the following command:
composer.documentation = For more information on the Composer registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
composer.dependencies = Dependencies composer.dependencies = Dependencies
composer.dependencies.development = Development Dependencies composer.dependencies.development = Development Dependencies
conan.details.repository = Repository conan.details.repository = Repository
conan.registry = Setup this registry from the command line: conan.registry = Setup this registry from the command line:
conan.install = To install the package using Conan, run the following command: conan.install = To install the package using Conan, run the following command:
conan.documentation = For more information on the Conan registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
conda.registry = Setup this registry as a Conda repository in your <code>.condarc</code> file: conda.registry = Setup this registry as a Conda repository in your <code>.condarc</code> file:
conda.install = To install the package using Conda, run the following command: conda.install = To install the package using Conda, run the following command:
conda.documentation = For more information on the Conda registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
conda.details.repository_site = Repository Site conda.details.repository_site = Repository Site
conda.details.documentation_site = Documentation Site conda.details.documentation_site = Documentation Site
container.details.type = Image Type container.details.type = Image Type
container.details.platform = Platform container.details.platform = Platform
container.pull = Pull the image from the command line: container.pull = Pull the image from the command line:
container.digest = Digest: container.digest = Digest:
container.documentation = For more information on the Container registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
container.multi_arch = OS / Arch container.multi_arch = OS / Arch
container.layers = Image Layers container.layers = Image Layers
container.labels = Labels container.labels = Labels
@ -3294,47 +3298,61 @@ container.labels.key = Key
container.labels.value = Value container.labels.value = Value
cran.registry = Setup this registry in your <code>Rprofile.site</code> file: cran.registry = Setup this registry in your <code>Rprofile.site</code> file:
cran.install = To install the package, run the following command: cran.install = To install the package, run the following command:
cran.documentation = For more information on the CRAN registry, see <a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io/en-us/packages/cran/">the documentation</a>.
debian.registry = Setup this registry from the command line: debian.registry = Setup this registry from the command line:
debian.registry.info = Choose $distribution and $component from the list below. debian.registry.info = Choose $distribution and $component from the list below.
debian.install = To install the package, run the following command: debian.install = To install the package, run the following command:
debian.documentation = For more information on the Debian registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
debian.repository = Repository Info debian.repository = Repository Info
debian.repository.distributions = Distributions debian.repository.distributions = Distributions
debian.repository.components = Components debian.repository.components = Components
debian.repository.architectures = Architectures debian.repository.architectures = Architectures
generic.download = Download package from the command line: generic.download = Download package from the command line:
generic.documentation = For more information on the generic registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
go.install = Install the package from the command line: go.install = Install the package from the command line:
go.documentation = For more information on the Go registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
helm.registry = Setup this registry from the command line: helm.registry = Setup this registry from the command line:
helm.install = To install the package, run the following command: helm.install = To install the package, run the following command:
helm.documentation = For more information on the Helm registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
maven.registry = Setup this registry in your project <code>pom.xml</code> file: maven.registry = Setup this registry in your project <code>pom.xml</code> file:
maven.install = To use the package include the following in the <code>dependencies</code> block in the <code>pom.xml</code> file: maven.install = To use the package include the following in the <code>dependencies</code> block in the <code>pom.xml</code> file:
maven.install2 = Run via command line: maven.install2 = Run via command line:
maven.download = To download the dependency, run via command line: maven.download = To download the dependency, run via command line:
maven.documentation = For more information on the Maven registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
nuget.registry = Setup this registry from the command line: nuget.registry = Setup this registry from the command line:
nuget.install = To install the package using NuGet, run the following command: nuget.install = To install the package using NuGet, run the following command:
nuget.documentation = For more information on the NuGet registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
nuget.dependency.framework = Target Framework nuget.dependency.framework = Target Framework
npm.registry = Setup this registry in your project <code>.npmrc</code> file: npm.registry = Setup this registry in your project <code>.npmrc</code> file:
npm.install = To install the package using npm, run the following command: npm.install = To install the package using npm, run the following command:
npm.install2 = or add it to the package.json file: npm.install2 = or add it to the package.json file:
npm.documentation = For more information on the npm registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
npm.dependencies = Dependencies npm.dependencies = Dependencies
npm.dependencies.development = Development Dependencies npm.dependencies.development = Development Dependencies
npm.dependencies.peer = Peer Dependencies npm.dependencies.peer = Peer Dependencies
npm.dependencies.optional = Optional Dependencies npm.dependencies.optional = Optional Dependencies
npm.details.tag = Tag npm.details.tag = Tag
pub.install = To install the package using Dart, run the following command: pub.install = To install the package using Dart, run the following command:
pub.documentation = For more information on the Pub registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
pypi.requires = Requires Python pypi.requires = Requires Python
pypi.install = To install the package using pip, run the following command: pypi.install = To install the package using pip, run the following command:
pypi.documentation = For more information on the PyPI registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
rpm.registry = Setup this registry from the command line: rpm.registry = Setup this registry from the command line:
rpm.install = To install the package, run the following command: rpm.install = To install the package, run the following command:
rpm.documentation = For more information on the RPM registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
rubygems.install = To install the package using gem, run the following command: rubygems.install = To install the package using gem, run the following command:
rubygems.install2 = or add it to the Gemfile: rubygems.install2 = or add it to the Gemfile:
rubygems.dependencies.runtime = Runtime Dependencies rubygems.dependencies.runtime = Runtime Dependencies
rubygems.dependencies.development = Development Dependencies rubygems.dependencies.development = Development Dependencies
rubygems.required.ruby = Requires Ruby version rubygems.required.ruby = Requires Ruby version
rubygems.required.rubygems = Requires RubyGem version rubygems.required.rubygems = Requires RubyGem version
rubygems.documentation = For more information on the RubyGems registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
swift.registry = Setup this registry from the command line: swift.registry = Setup this registry from the command line:
swift.install = Add the package in your <code>Package.swift</code> file: swift.install = Add the package in your <code>Package.swift</code> file:
swift.install2 = and run the following command: swift.install2 = and run the following command:
swift.documentation = For more information on the Swift registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
vagrant.install = To add a Vagrant box, run the following command: vagrant.install = To add a Vagrant box, run the following command:
vagrant.documentation = For more information on the Vagrant registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
settings.link = Link this package to a repository settings.link = Link this package to a repository
settings.link.description = If you link a package with a repository, the package is listed in the repository's package list. settings.link.description = If you link a package with a repository, the package is listed in the repository's package list.
settings.link.select = Select Repository settings.link.select = Select Repository

210
package-lock.json generated
View File

@ -30,7 +30,6 @@
"jquery.are-you-sure": "1.9.0", "jquery.are-you-sure": "1.9.0",
"katex": "0.16.8", "katex": "0.16.8",
"license-checker-webpack-plugin": "0.2.1", "license-checker-webpack-plugin": "0.2.1",
"lightningcss-loader": "2.1.0",
"mermaid": "10.2.3", "mermaid": "10.2.3",
"mini-css-extract-plugin": "2.7.6", "mini-css-extract-plugin": "2.7.6",
"minimatch": "9.0.2", "minimatch": "9.0.2",
@ -4011,17 +4010,6 @@
"node": ">=6" "node": ">=6"
} }
}, },
"node_modules/detect-libc": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz",
"integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==",
"bin": {
"detect-libc": "bin/detect-libc.js"
},
"engines": {
"node": ">=0.10"
}
},
"node_modules/diff": { "node_modules/diff": {
"version": "5.1.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz", "resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz",
@ -6729,204 +6717,6 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/lightningcss": {
"version": "1.21.5",
"resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.21.5.tgz",
"integrity": "sha512-/pEUPeih2EwIx9n4T82aOG6CInN83tl/mWlw6B5gWLf36UplQi1L+5p3FUHsdt4fXVfOkkh9KIaM3owoq7ss8A==",
"dependencies": {
"detect-libc": "^1.0.3"
},
"engines": {
"node": ">= 12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
},
"optionalDependencies": {
"lightningcss-darwin-arm64": "1.21.5",
"lightningcss-darwin-x64": "1.21.5",
"lightningcss-linux-arm-gnueabihf": "1.21.5",
"lightningcss-linux-arm64-gnu": "1.21.5",
"lightningcss-linux-arm64-musl": "1.21.5",
"lightningcss-linux-x64-gnu": "1.21.5",
"lightningcss-linux-x64-musl": "1.21.5",
"lightningcss-win32-x64-msvc": "1.21.5"
}
},
"node_modules/lightningcss-darwin-arm64": {
"version": "1.21.5",
"resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.21.5.tgz",
"integrity": "sha512-z05hyLX85WY0UfhkFUOrWEFqD69lpVAmgl3aDzMKlIZJGygbhbegqb4PV8qfUrKKNBauut/qVNPKZglhTaDDxA==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/lightningcss-darwin-x64": {
"version": "1.21.5",
"resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.21.5.tgz",
"integrity": "sha512-MSJhmej/U9MrdPxDk7+FWhO8+UqVoZUHG4VvKT5RQ4RJtqtANTiWiI97LvoVNMtdMnHaKs1Pkji6wHUFxjJsHQ==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/lightningcss-linux-arm-gnueabihf": {
"version": "1.21.5",
"resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.21.5.tgz",
"integrity": "sha512-xN6+5/JsMrbZHL1lPl+MiNJ3Xza12ueBKPepiyDCFQzlhFRTj7D0LG+cfNTzPBTO8KcYQynLpl1iBB8LGp3Xtw==",
"cpu": [
"arm"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/lightningcss-linux-arm64-gnu": {
"version": "1.21.5",
"resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.21.5.tgz",
"integrity": "sha512-KfzFNhC4XTbmG3ma/xcTs/IhCwieW89XALIusKmnV0N618ZDXEB0XjWOYQRCXeK9mfqPdbTBpurEHV/XZtkniQ==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/lightningcss-linux-arm64-musl": {
"version": "1.21.5",
"resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.21.5.tgz",
"integrity": "sha512-bc0GytQO5Mn9QM6szaZ+31fQHNdidgpM1sSCwzPItz8hg3wOvKl8039rU0veMJV3ZgC9z0ypNRceLrSHeRHmXw==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/lightningcss-linux-x64-gnu": {
"version": "1.21.5",
"resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.21.5.tgz",
"integrity": "sha512-JwMbgypPQgc2kW2av3OwzZ8cbrEuIiDiXPJdXRE6aVxu67yHauJawQLqJKTGUhiAhy6iLDG8Wg0a3/ziL+m+Kw==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/lightningcss-linux-x64-musl": {
"version": "1.21.5",
"resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.21.5.tgz",
"integrity": "sha512-Ib8b6IQ/OR/VrPU6YBgy4T3QnuHY7DUa95O+nz+cwrTkMSN6fuHcTcIaz4t8TJ6HI5pl3uxUOZjmtls2pyQWow==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/lightningcss-loader": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/lightningcss-loader/-/lightningcss-loader-2.1.0.tgz",
"integrity": "sha512-mB+M/lvs/GdXT4yc8ZiNgLUAbYpPI9grDyC3ybz/Zo6s4GZv53iZnLTnkJT/Qm3Sh89dbFUm+omoHFXCfZtcXw==",
"dependencies": {
"browserslist": "^4.21.4",
"lightningcss": "^1.16.0",
"webpack-sources": "^3.2.3"
},
"peerDependencies": {
"webpack": ">=5"
}
},
"node_modules/lightningcss-loader/node_modules/webpack-sources": {
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz",
"integrity": "sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==",
"engines": {
"node": ">=10.13.0"
}
},
"node_modules/lightningcss-win32-x64-msvc": {
"version": "1.21.5",
"resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.21.5.tgz",
"integrity": "sha512-A8cSi8lUpBeVmoF+DqqW7cd0FemDbCuKr490IXdjyeI+KL8adpSKUs8tcqO0OXPh1EoDqK7JNkD/dELmd4Iz5g==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/lines-and-columns": { "node_modules/lines-and-columns": {
"version": "1.2.4", "version": "1.2.4",
"resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz",

View File

@ -29,7 +29,6 @@
"jquery.are-you-sure": "1.9.0", "jquery.are-you-sure": "1.9.0",
"katex": "0.16.8", "katex": "0.16.8",
"license-checker-webpack-plugin": "0.2.1", "license-checker-webpack-plugin": "0.2.1",
"lightningcss-loader": "2.1.0",
"mermaid": "10.2.3", "mermaid": "10.2.3",
"mini-css-extract-plugin": "2.7.6", "mini-css-extract-plugin": "2.7.6",
"minimatch": "9.0.2", "minimatch": "9.0.2",

View File

@ -129,22 +129,12 @@ func generateTaskContext(t *actions_model.ActionTask) *structpb.Struct {
baseRef := "" baseRef := ""
headRef := "" headRef := ""
ref := t.Job.Run.Ref
sha := t.Job.Run.CommitSHA
if pullPayload, err := t.Job.Run.GetPullRequestEventPayload(); err == nil && pullPayload.PullRequest != nil && pullPayload.PullRequest.Base != nil && pullPayload.PullRequest.Head != nil { if pullPayload, err := t.Job.Run.GetPullRequestEventPayload(); err == nil && pullPayload.PullRequest != nil && pullPayload.PullRequest.Base != nil && pullPayload.PullRequest.Head != nil {
baseRef = pullPayload.PullRequest.Base.Ref baseRef = pullPayload.PullRequest.Base.Ref
headRef = pullPayload.PullRequest.Head.Ref headRef = pullPayload.PullRequest.Head.Ref
// if the TriggerEvent is pull_request_target, ref and sha need to be set according to the base of pull request
// In GitHub's documentation, ref should be the branch or tag that triggered workflow. But when the TriggerEvent is pull_request_target,
// the ref will be the base branch.
if t.Job.Run.TriggerEvent == actions_module.GithubEventPullRequestTarget {
ref = git.BranchPrefix + pullPayload.PullRequest.Base.Name
sha = pullPayload.PullRequest.Base.Sha
}
} }
refName := git.RefName(ref) refName := git.RefName(t.Job.Run.Ref)
taskContext, err := structpb.NewStruct(map[string]any{ taskContext, err := structpb.NewStruct(map[string]any{
// standard contexts, see https://docs.github.com/en/actions/learn-github-actions/contexts#github-context // standard contexts, see https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
@ -163,7 +153,7 @@ func generateTaskContext(t *actions_model.ActionTask) *structpb.Struct {
"graphql_url": "", // string, The URL of the GitHub GraphQL API. "graphql_url": "", // string, The URL of the GitHub GraphQL API.
"head_ref": headRef, // string, The head_ref or source branch of the pull request in a workflow run. This property is only available when the event that triggers a workflow run is either pull_request or pull_request_target. "head_ref": headRef, // string, The head_ref or source branch of the pull request in a workflow run. This property is only available when the event that triggers a workflow run is either pull_request or pull_request_target.
"job": fmt.Sprint(t.JobID), // string, The job_id of the current job. "job": fmt.Sprint(t.JobID), // string, The job_id of the current job.
"ref": ref, // string, The fully-formed ref of the branch or tag that triggered the workflow run. For workflows triggered by push, this is the branch or tag ref that was pushed. For workflows triggered by pull_request, this is the pull request merge branch. For workflows triggered by release, this is the release tag created. For other triggers, this is the branch or tag ref that triggered the workflow run. This is only set if a branch or tag is available for the event type. The ref given is fully-formed, meaning that for branches the format is refs/heads/<branch_name>, for pull requests it is refs/pull/<pr_number>/merge, and for tags it is refs/tags/<tag_name>. For example, refs/heads/feature-branch-1. "ref": t.Job.Run.Ref, // string, The fully-formed ref of the branch or tag that triggered the workflow run. For workflows triggered by push, this is the branch or tag ref that was pushed. For workflows triggered by pull_request, this is the pull request merge branch. For workflows triggered by release, this is the release tag created. For other triggers, this is the branch or tag ref that triggered the workflow run. This is only set if a branch or tag is available for the event type. The ref given is fully-formed, meaning that for branches the format is refs/heads/<branch_name>, for pull requests it is refs/pull/<pr_number>/merge, and for tags it is refs/tags/<tag_name>. For example, refs/heads/feature-branch-1.
"ref_name": refName.ShortName(), // string, The short ref name of the branch or tag that triggered the workflow run. This value matches the branch or tag name shown on GitHub. For example, feature-branch-1. "ref_name": refName.ShortName(), // string, The short ref name of the branch or tag that triggered the workflow run. This value matches the branch or tag name shown on GitHub. For example, feature-branch-1.
"ref_protected": false, // boolean, true if branch protections are configured for the ref that triggered the workflow run. "ref_protected": false, // boolean, true if branch protections are configured for the ref that triggered the workflow run.
"ref_type": refName.RefType(), // string, The type of ref that triggered the workflow run. Valid values are branch or tag. "ref_type": refName.RefType(), // string, The type of ref that triggered the workflow run. Valid values are branch or tag.
@ -177,7 +167,7 @@ func generateTaskContext(t *actions_model.ActionTask) *structpb.Struct {
"run_attempt": fmt.Sprint(t.Job.Attempt), // string, A unique number for each attempt of a particular workflow run in a repository. This number begins at 1 for the workflow run's first attempt, and increments with each re-run. "run_attempt": fmt.Sprint(t.Job.Attempt), // string, A unique number for each attempt of a particular workflow run in a repository. This number begins at 1 for the workflow run's first attempt, and increments with each re-run.
"secret_source": "Actions", // string, The source of a secret used in a workflow. Possible values are None, Actions, Dependabot, or Codespaces. "secret_source": "Actions", // string, The source of a secret used in a workflow. Possible values are None, Actions, Dependabot, or Codespaces.
"server_url": setting.AppURL, // string, The URL of the GitHub server. For example: https://github.com. "server_url": setting.AppURL, // string, The URL of the GitHub server. For example: https://github.com.
"sha": sha, // string, The commit SHA that triggered the workflow. The value of this commit SHA depends on the event that triggered the workflow. For more information, see "Events that trigger workflows." For example, ffac537e6cbbf934b08745a378932722df287a53. "sha": t.Job.Run.CommitSHA, // string, The commit SHA that triggered the workflow. The value of this commit SHA depends on the event that triggered the workflow. For more information, see "Events that trigger workflows." For example, ffac537e6cbbf934b08745a378932722df287a53.
"token": t.Token, // string, A token to authenticate on behalf of the GitHub App installed on your repository. This is functionally equivalent to the GITHUB_TOKEN secret. For more information, see "Automatic token authentication." "token": t.Token, // string, A token to authenticate on behalf of the GitHub App installed on your repository. This is functionally equivalent to the GITHUB_TOKEN secret. For more information, see "Automatic token authentication."
"triggering_actor": "", // string, The username of the user that initiated the workflow run. If the workflow run is a re-run, this value may differ from github.actor. Any workflow re-runs will use the privileges of github.actor, even if the actor initiating the re-run (github.triggering_actor) has different privileges. "triggering_actor": "", // string, The username of the user that initiated the workflow run. If the workflow run is a re-run, this value may differ from github.actor. Any workflow re-runs will use the privileges of github.actor, even if the actor initiating the re-run (github.triggering_actor) has different privileges.
"workflow": t.Job.Run.WorkflowID, // string, The name of the workflow. If the workflow file doesn't specify a name, the value of this property is the full path of the workflow file in the repository. "workflow": t.Job.Run.WorkflowID, // string, The name of the workflow. If the workflow file doesn't specify a name, the value of this property is the full path of the workflow file in the repository.

View File

@ -219,7 +219,7 @@ func GetRawFileOrLFS(ctx *context.APIContext) {
common.ServeContentByReadSeeker(ctx.Base, ctx.Repo.TreePath, lastModified, lfsDataRc) common.ServeContentByReadSeeker(ctx.Base, ctx.Repo.TreePath, lastModified, lfsDataRc)
} }
func getBlobForEntry(ctx *context.APIContext) (blob *git.Blob, entry *git.TreeEntry, lastModified *time.Time) { func getBlobForEntry(ctx *context.APIContext) (blob *git.Blob, entry *git.TreeEntry, lastModified time.Time) {
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(ctx.Repo.TreePath) entry, err := ctx.Repo.Commit.GetTreeEntryByPath(ctx.Repo.TreePath)
if err != nil { if err != nil {
if git.IsErrNotExist(err) { if git.IsErrNotExist(err) {
@ -227,23 +227,23 @@ func getBlobForEntry(ctx *context.APIContext) (blob *git.Blob, entry *git.TreeEn
} else { } else {
ctx.Error(http.StatusInternalServerError, "GetTreeEntryByPath", err) ctx.Error(http.StatusInternalServerError, "GetTreeEntryByPath", err)
} }
return nil, nil, nil return
} }
if entry.IsDir() || entry.IsSubModule() { if entry.IsDir() || entry.IsSubModule() {
ctx.NotFound("getBlobForEntry", nil) ctx.NotFound("getBlobForEntry", nil)
return nil, nil, nil return
} }
info, _, err := git.Entries([]*git.TreeEntry{entry}).GetCommitsInfo(ctx, ctx.Repo.Commit, path.Dir("/" + ctx.Repo.TreePath)[1:]) info, _, err := git.Entries([]*git.TreeEntry{entry}).GetCommitsInfo(ctx, ctx.Repo.Commit, path.Dir("/" + ctx.Repo.TreePath)[1:])
if err != nil { if err != nil {
ctx.Error(http.StatusInternalServerError, "GetCommitsInfo", err) ctx.Error(http.StatusInternalServerError, "GetCommitsInfo", err)
return nil, nil, nil return
} }
if len(info) == 1 { if len(info) == 1 {
// Not Modified // Not Modified
lastModified = &info[0].Commit.Committer.When lastModified = info[0].Commit.Committer.When
} }
blob = entry.Blob() blob = entry.Blob()

View File

@ -195,7 +195,7 @@ func SearchIssues(ctx *context.APIContext) {
} }
var issueIDs []int64 var issueIDs []int64
if len(keyword) > 0 && len(repoIDs) > 0 { if len(keyword) > 0 && len(repoIDs) > 0 {
if issueIDs, err = issue_indexer.SearchIssuesByKeyword(ctx, repoIDs, keyword, ctx.FormString("state")); err != nil { if issueIDs, err = issue_indexer.SearchIssuesByKeyword(ctx, repoIDs, keyword); err != nil {
ctx.Error(http.StatusInternalServerError, "SearchIssuesByKeyword", err) ctx.Error(http.StatusInternalServerError, "SearchIssuesByKeyword", err)
return return
} }
@ -394,7 +394,7 @@ func ListIssues(ctx *context.APIContext) {
var issueIDs []int64 var issueIDs []int64
var labelIDs []int64 var labelIDs []int64
if len(keyword) > 0 { if len(keyword) > 0 {
issueIDs, err = issue_indexer.SearchIssuesByKeyword(ctx, []int64{ctx.Repo.Repository.ID}, keyword, ctx.FormString("state")) issueIDs, err = issue_indexer.SearchIssuesByKeyword(ctx, []int64{ctx.Repo.Repository.ID}, keyword)
if err != nil { if err != nil {
ctx.Error(http.StatusInternalServerError, "SearchIssuesByKeyword", err) ctx.Error(http.StatusInternalServerError, "SearchIssuesByKeyword", err)
return return

View File

@ -298,26 +298,26 @@ func ClearIssueLabels(ctx *context.APIContext) {
ctx.Status(http.StatusNoContent) ctx.Status(http.StatusNoContent)
} }
func prepareForReplaceOrAdd(ctx *context.APIContext, form api.IssueLabelsOption) (*issues_model.Issue, []*issues_model.Label, error) { func prepareForReplaceOrAdd(ctx *context.APIContext, form api.IssueLabelsOption) (issue *issues_model.Issue, labels []*issues_model.Label, err error) {
issue, err := issues_model.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) issue, err = issues_model.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
if err != nil { if err != nil {
if issues_model.IsErrIssueNotExist(err) { if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound() ctx.NotFound()
} else { } else {
ctx.Error(http.StatusInternalServerError, "GetIssueByIndex", err) ctx.Error(http.StatusInternalServerError, "GetIssueByIndex", err)
} }
return nil, nil, err return
} }
labels, err := issues_model.GetLabelsByIDs(form.Labels) labels, err = issues_model.GetLabelsByIDs(form.Labels)
if err != nil { if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelsByIDs", err) ctx.Error(http.StatusInternalServerError, "GetLabelsByIDs", err)
return nil, nil, err return
} }
if !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) { if !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) {
ctx.Status(http.StatusForbidden) ctx.Status(http.StatusForbidden)
return nil, nil, nil return
} }
return issue, labels, err return issue, labels, err

View File

@ -15,7 +15,7 @@ import (
) )
// ServeBlob download a git.Blob // ServeBlob download a git.Blob
func ServeBlob(ctx *context.Base, filePath string, blob *git.Blob, lastModified *time.Time) error { func ServeBlob(ctx *context.Base, filePath string, blob *git.Blob, lastModified time.Time) error {
if httpcache.HandleGenericETagTimeCache(ctx.Req, ctx.Resp, `"`+blob.ID.String()+`"`, lastModified) { if httpcache.HandleGenericETagTimeCache(ctx.Req, ctx.Resp, `"`+blob.ID.String()+`"`, lastModified) {
return nil return nil
} }
@ -38,6 +38,6 @@ func ServeContentByReader(ctx *context.Base, filePath string, size int64, reader
httplib.ServeContentByReader(ctx.Req, ctx.Resp, filePath, size, reader) httplib.ServeContentByReader(ctx.Req, ctx.Resp, filePath, size, reader)
} }
func ServeContentByReadSeeker(ctx *context.Base, filePath string, modTime *time.Time, reader io.ReadSeeker) { func ServeContentByReadSeeker(ctx *context.Base, filePath string, modTime time.Time, reader io.ReadSeeker) {
httplib.ServeContentByReadSeeker(ctx.Req, ctx.Resp, filePath, modTime, reader) httplib.ServeContentByReadSeeker(ctx.Req, ctx.Resp, filePath, modTime, reader)
} }

View File

@ -497,23 +497,23 @@ func createUserInContext(ctx *context.Context, tpl base.TplName, form any, u *us
hasUser, err = user_model.GetUser(user) hasUser, err = user_model.GetUser(user)
if !hasUser || err != nil { if !hasUser || err != nil {
ctx.ServerError("UserLinkAccount", err) ctx.ServerError("UserLinkAccount", err)
return false return
} }
} }
// TODO: probably we should respect 'remember' user's choice... // TODO: probably we should respect 'remember' user's choice...
linkAccount(ctx, user, *gothUser, true) linkAccount(ctx, user, *gothUser, true)
return false // user is already created here, all redirects are handled return // user is already created here, all redirects are handled
} else if setting.OAuth2Client.AccountLinking == setting.OAuth2AccountLinkingLogin { } else if setting.OAuth2Client.AccountLinking == setting.OAuth2AccountLinkingLogin {
showLinkingLogin(ctx, *gothUser) showLinkingLogin(ctx, *gothUser)
return false // user will be created only after linking login return // user will be created only after linking login
} }
} }
// handle error without template // handle error without template
if len(tpl) == 0 { if len(tpl) == 0 {
ctx.ServerError("CreateUser", err) ctx.ServerError("CreateUser", err)
return false return
} }
// handle error with template // handle error with template
@ -542,7 +542,7 @@ func createUserInContext(ctx *context.Context, tpl base.TplName, form any, u *us
default: default:
ctx.ServerError("CreateUser", err) ctx.ServerError("CreateUser", err)
} }
return false return
} }
log.Trace("Account created: %s", u.Name) log.Trace("Account created: %s", u.Name)
return true return true
@ -559,7 +559,7 @@ func handleUserCreated(ctx *context.Context, u *user_model.User, gothUser *goth.
u.SetLastLogin() u.SetLastLogin()
if err := user_model.UpdateUserCols(ctx, u, "is_admin", "is_active", "last_login_unix"); err != nil { if err := user_model.UpdateUserCols(ctx, u, "is_admin", "is_active", "last_login_unix"); err != nil {
ctx.ServerError("UpdateUser", err) ctx.ServerError("UpdateUser", err)
return false return
} }
} }
@ -577,7 +577,7 @@ func handleUserCreated(ctx *context.Context, u *user_model.User, gothUser *goth.
if setting.Service.RegisterManualConfirm { if setting.Service.RegisterManualConfirm {
ctx.Data["ManualActivationOnly"] = true ctx.Data["ManualActivationOnly"] = true
ctx.HTML(http.StatusOK, TplActivate) ctx.HTML(http.StatusOK, TplActivate)
return false return
} }
mailer.SendActivateAccountMail(ctx.Locale, u) mailer.SendActivateAccountMail(ctx.Locale, u)
@ -592,7 +592,7 @@ func handleUserCreated(ctx *context.Context, u *user_model.User, gothUser *goth.
log.Error("Set cache(MailResendLimit) fail: %v", err) log.Error("Set cache(MailResendLimit) fail: %v", err)
} }
} }
return false return
} }
return true return true

View File

@ -15,7 +15,6 @@ import (
"code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/storage" "code.gitea.io/gitea/modules/storage"
"code.gitea.io/gitea/modules/upload" "code.gitea.io/gitea/modules/upload"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/routers/common" "code.gitea.io/gitea/routers/common"
"code.gitea.io/gitea/services/attachment" "code.gitea.io/gitea/services/attachment"
repo_service "code.gitea.io/gitea/services/repository" repo_service "code.gitea.io/gitea/services/repository"
@ -149,7 +148,7 @@ func ServeAttachment(ctx *context.Context, uuid string) {
} }
defer fr.Close() defer fr.Close()
common.ServeContentByReadSeeker(ctx.Base, attach.Name, util.ToPointer(attach.CreatedUnix.AsTime()), fr) common.ServeContentByReadSeeker(ctx.Base, attach.Name, attach.CreatedUnix.AsTime(), fr)
} }
// GetAttachment serve attachments // GetAttachment serve attachments

View File

@ -20,7 +20,7 @@ import (
) )
// ServeBlobOrLFS download a git.Blob redirecting to LFS if necessary // ServeBlobOrLFS download a git.Blob redirecting to LFS if necessary
func ServeBlobOrLFS(ctx *context.Context, blob *git.Blob, lastModified *time.Time) error { func ServeBlobOrLFS(ctx *context.Context, blob *git.Blob, lastModified time.Time) error {
if httpcache.HandleGenericETagTimeCache(ctx.Req, ctx.Resp, `"`+blob.ID.String()+`"`, lastModified) { if httpcache.HandleGenericETagTimeCache(ctx.Req, ctx.Resp, `"`+blob.ID.String()+`"`, lastModified) {
return nil return nil
} }
@ -82,7 +82,7 @@ func ServeBlobOrLFS(ctx *context.Context, blob *git.Blob, lastModified *time.Tim
return common.ServeBlob(ctx.Base, ctx.Repo.TreePath, blob, lastModified) return common.ServeBlob(ctx.Base, ctx.Repo.TreePath, blob, lastModified)
} }
func getBlobForEntry(ctx *context.Context) (blob *git.Blob, lastModified *time.Time) { func getBlobForEntry(ctx *context.Context) (blob *git.Blob, lastModified time.Time) {
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(ctx.Repo.TreePath) entry, err := ctx.Repo.Commit.GetTreeEntryByPath(ctx.Repo.TreePath)
if err != nil { if err != nil {
if git.IsErrNotExist(err) { if git.IsErrNotExist(err) {
@ -90,23 +90,23 @@ func getBlobForEntry(ctx *context.Context) (blob *git.Blob, lastModified *time.T
} else { } else {
ctx.ServerError("GetTreeEntryByPath", err) ctx.ServerError("GetTreeEntryByPath", err)
} }
return nil, nil return
} }
if entry.IsDir() || entry.IsSubModule() { if entry.IsDir() || entry.IsSubModule() {
ctx.NotFound("getBlobForEntry", nil) ctx.NotFound("getBlobForEntry", nil)
return nil, nil return
} }
info, _, err := git.Entries([]*git.TreeEntry{entry}).GetCommitsInfo(ctx, ctx.Repo.Commit, path.Dir("/" + ctx.Repo.TreePath)[1:]) info, _, err := git.Entries([]*git.TreeEntry{entry}).GetCommitsInfo(ctx, ctx.Repo.Commit, path.Dir("/" + ctx.Repo.TreePath)[1:])
if err != nil { if err != nil {
ctx.ServerError("GetCommitsInfo", err) ctx.ServerError("GetCommitsInfo", err)
return nil, nil return
} }
if len(info) == 1 { if len(info) == 1 {
// Not Modified // Not Modified
lastModified = &info[0].Commit.Committer.When lastModified = info[0].Commit.Committer.When
} }
blob = entry.Blob() blob = entry.Blob()
@ -148,7 +148,7 @@ func DownloadByID(ctx *context.Context) {
} }
return return
} }
if err = common.ServeBlob(ctx.Base, ctx.Repo.TreePath, blob, nil); err != nil { if err = common.ServeBlob(ctx.Base, ctx.Repo.TreePath, blob, time.Time{}); err != nil {
ctx.ServerError("ServeBlob", err) ctx.ServerError("ServeBlob", err)
} }
} }
@ -164,7 +164,7 @@ func DownloadByIDOrLFS(ctx *context.Context) {
} }
return return
} }
if err = ServeBlobOrLFS(ctx, blob, nil); err != nil { if err = ServeBlobOrLFS(ctx, blob, time.Time{}); err != nil {
ctx.ServerError("ServeBlob", err) ctx.ServerError("ServeBlob", err)
} }
} }

View File

@ -56,13 +56,13 @@ func CorsHandler() func(next http.Handler) http.Handler {
} }
// httpBase implementation git smart HTTP protocol // httpBase implementation git smart HTTP protocol
func httpBase(ctx *context.Context) *serviceHandler { func httpBase(ctx *context.Context) (h *serviceHandler) {
username := ctx.Params(":username") username := ctx.Params(":username")
reponame := strings.TrimSuffix(ctx.Params(":reponame"), ".git") reponame := strings.TrimSuffix(ctx.Params(":reponame"), ".git")
if ctx.FormString("go-get") == "1" { if ctx.FormString("go-get") == "1" {
context.EarlyResponseForGoGetMeta(ctx) context.EarlyResponseForGoGetMeta(ctx)
return nil return
} }
var isPull, receivePack bool var isPull, receivePack bool
@ -101,7 +101,7 @@ func httpBase(ctx *context.Context) *serviceHandler {
owner := ctx.ContextUser owner := ctx.ContextUser
if !owner.IsOrganization() && !owner.IsActive { if !owner.IsOrganization() && !owner.IsActive {
ctx.PlainText(http.StatusForbidden, "Repository cannot be accessed. You cannot push or open issues/pull-requests.") ctx.PlainText(http.StatusForbidden, "Repository cannot be accessed. You cannot push or open issues/pull-requests.")
return nil return
} }
repoExist := true repoExist := true
@ -110,19 +110,19 @@ func httpBase(ctx *context.Context) *serviceHandler {
if repo_model.IsErrRepoNotExist(err) { if repo_model.IsErrRepoNotExist(err) {
if redirectRepoID, err := repo_model.LookupRedirect(owner.ID, reponame); err == nil { if redirectRepoID, err := repo_model.LookupRedirect(owner.ID, reponame); err == nil {
context.RedirectToRepo(ctx.Base, redirectRepoID) context.RedirectToRepo(ctx.Base, redirectRepoID)
return nil return
} }
repoExist = false repoExist = false
} else { } else {
ctx.ServerError("GetRepositoryByName", err) ctx.ServerError("GetRepositoryByName", err)
return nil return
} }
} }
// Don't allow pushing if the repo is archived // Don't allow pushing if the repo is archived
if repoExist && repo.IsArchived && !isPull { if repoExist && repo.IsArchived && !isPull {
ctx.PlainText(http.StatusForbidden, "This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.") ctx.PlainText(http.StatusForbidden, "This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.")
return nil return
} }
// Only public pull don't need auth. // Only public pull don't need auth.
@ -136,7 +136,7 @@ func httpBase(ctx *context.Context) *serviceHandler {
if isPublicPull { if isPublicPull {
if err := repo.LoadOwner(ctx); err != nil { if err := repo.LoadOwner(ctx); err != nil {
ctx.ServerError("LoadOwner", err) ctx.ServerError("LoadOwner", err)
return nil return
} }
askAuth = askAuth || (repo.Owner.Visibility != structs.VisibleTypePublic) askAuth = askAuth || (repo.Owner.Visibility != structs.VisibleTypePublic)
@ -149,12 +149,12 @@ func httpBase(ctx *context.Context) *serviceHandler {
// TODO: support digit auth - which would be Authorization header with digit // TODO: support digit auth - which would be Authorization header with digit
ctx.Resp.Header().Set("WWW-Authenticate", "Basic realm=\".\"") ctx.Resp.Header().Set("WWW-Authenticate", "Basic realm=\".\"")
ctx.Error(http.StatusUnauthorized) ctx.Error(http.StatusUnauthorized)
return nil return
} }
context.CheckRepoScopedToken(ctx, repo, auth_model.GetScopeLevelFromAccessMode(accessMode)) context.CheckRepoScopedToken(ctx, repo, auth_model.GetScopeLevelFromAccessMode(accessMode))
if ctx.Written() { if ctx.Written() {
return nil return
} }
if ctx.IsBasicAuth && ctx.Data["IsApiToken"] != true && ctx.Data["IsActionsToken"] != true { if ctx.IsBasicAuth && ctx.Data["IsApiToken"] != true && ctx.Data["IsActionsToken"] != true {
@ -162,16 +162,16 @@ func httpBase(ctx *context.Context) *serviceHandler {
if err == nil { if err == nil {
// TODO: This response should be changed to "invalid credentials" for security reasons once the expectation behind it (creating an app token to authenticate) is properly documented // TODO: This response should be changed to "invalid credentials" for security reasons once the expectation behind it (creating an app token to authenticate) is properly documented
ctx.PlainText(http.StatusUnauthorized, "Users with two-factor authentication enabled cannot perform HTTP/HTTPS operations via plain username and password. Please create and use a personal access token on the user settings page") ctx.PlainText(http.StatusUnauthorized, "Users with two-factor authentication enabled cannot perform HTTP/HTTPS operations via plain username and password. Please create and use a personal access token on the user settings page")
return nil return
} else if !auth_model.IsErrTwoFactorNotEnrolled(err) { } else if !auth_model.IsErrTwoFactorNotEnrolled(err) {
ctx.ServerError("IsErrTwoFactorNotEnrolled", err) ctx.ServerError("IsErrTwoFactorNotEnrolled", err)
return nil return
} }
} }
if !ctx.Doer.IsActive || ctx.Doer.ProhibitLogin { if !ctx.Doer.IsActive || ctx.Doer.ProhibitLogin {
ctx.PlainText(http.StatusForbidden, "Your account is disabled.") ctx.PlainText(http.StatusForbidden, "Your account is disabled.")
return nil return
} }
environ = []string{ environ = []string{
@ -193,23 +193,23 @@ func httpBase(ctx *context.Context) *serviceHandler {
task, err := actions_model.GetTaskByID(ctx, taskID) task, err := actions_model.GetTaskByID(ctx, taskID)
if err != nil { if err != nil {
ctx.ServerError("GetTaskByID", err) ctx.ServerError("GetTaskByID", err)
return nil return
} }
if task.RepoID != repo.ID { if task.RepoID != repo.ID {
ctx.PlainText(http.StatusForbidden, "User permission denied") ctx.PlainText(http.StatusForbidden, "User permission denied")
return nil return
} }
if task.IsForkPullRequest { if task.IsForkPullRequest {
if accessMode > perm.AccessModeRead { if accessMode > perm.AccessModeRead {
ctx.PlainText(http.StatusForbidden, "User permission denied") ctx.PlainText(http.StatusForbidden, "User permission denied")
return nil return
} }
environ = append(environ, fmt.Sprintf("%s=%d", repo_module.EnvActionPerm, perm.AccessModeRead)) environ = append(environ, fmt.Sprintf("%s=%d", repo_module.EnvActionPerm, perm.AccessModeRead))
} else { } else {
if accessMode > perm.AccessModeWrite { if accessMode > perm.AccessModeWrite {
ctx.PlainText(http.StatusForbidden, "User permission denied") ctx.PlainText(http.StatusForbidden, "User permission denied")
return nil return
} }
environ = append(environ, fmt.Sprintf("%s=%d", repo_module.EnvActionPerm, perm.AccessModeWrite)) environ = append(environ, fmt.Sprintf("%s=%d", repo_module.EnvActionPerm, perm.AccessModeWrite))
} }
@ -217,18 +217,18 @@ func httpBase(ctx *context.Context) *serviceHandler {
p, err := access_model.GetUserRepoPermission(ctx, repo, ctx.Doer) p, err := access_model.GetUserRepoPermission(ctx, repo, ctx.Doer)
if err != nil { if err != nil {
ctx.ServerError("GetUserRepoPermission", err) ctx.ServerError("GetUserRepoPermission", err)
return nil return
} }
if !p.CanAccess(accessMode, unitType) { if !p.CanAccess(accessMode, unitType) {
ctx.PlainText(http.StatusNotFound, "Repository not found") ctx.PlainText(http.StatusNotFound, "Repository not found")
return nil return
} }
} }
if !isPull && repo.IsMirror { if !isPull && repo.IsMirror {
ctx.PlainText(http.StatusForbidden, "mirror repository is read-only") ctx.PlainText(http.StatusForbidden, "mirror repository is read-only")
return nil return
} }
} }
@ -246,34 +246,34 @@ func httpBase(ctx *context.Context) *serviceHandler {
if !repoExist { if !repoExist {
if !receivePack { if !receivePack {
ctx.PlainText(http.StatusNotFound, "Repository not found") ctx.PlainText(http.StatusNotFound, "Repository not found")
return nil return
} }
if isWiki { // you cannot send wiki operation before create the repository if isWiki { // you cannot send wiki operation before create the repository
ctx.PlainText(http.StatusNotFound, "Repository not found") ctx.PlainText(http.StatusNotFound, "Repository not found")
return nil return
} }
if owner.IsOrganization() && !setting.Repository.EnablePushCreateOrg { if owner.IsOrganization() && !setting.Repository.EnablePushCreateOrg {
ctx.PlainText(http.StatusForbidden, "Push to create is not enabled for organizations.") ctx.PlainText(http.StatusForbidden, "Push to create is not enabled for organizations.")
return nil return
} }
if !owner.IsOrganization() && !setting.Repository.EnablePushCreateUser { if !owner.IsOrganization() && !setting.Repository.EnablePushCreateUser {
ctx.PlainText(http.StatusForbidden, "Push to create is not enabled for users.") ctx.PlainText(http.StatusForbidden, "Push to create is not enabled for users.")
return nil return
} }
// Return dummy payload if GET receive-pack // Return dummy payload if GET receive-pack
if ctx.Req.Method == http.MethodGet { if ctx.Req.Method == http.MethodGet {
dummyInfoRefs(ctx) dummyInfoRefs(ctx)
return nil return
} }
repo, err = repo_service.PushCreateRepo(ctx, ctx.Doer, owner, reponame) repo, err = repo_service.PushCreateRepo(ctx, ctx.Doer, owner, reponame)
if err != nil { if err != nil {
log.Error("pushCreateRepo: %v", err) log.Error("pushCreateRepo: %v", err)
ctx.Status(http.StatusNotFound) ctx.Status(http.StatusNotFound)
return nil return
} }
} }
@ -282,11 +282,11 @@ func httpBase(ctx *context.Context) *serviceHandler {
if _, err := repo.GetUnit(ctx, unit.TypeWiki); err != nil { if _, err := repo.GetUnit(ctx, unit.TypeWiki); err != nil {
if repo_model.IsErrUnitTypeNotExist(err) { if repo_model.IsErrUnitTypeNotExist(err) {
ctx.PlainText(http.StatusForbidden, "repository wiki is disabled") ctx.PlainText(http.StatusForbidden, "repository wiki is disabled")
return nil return
} }
log.Error("Failed to get the wiki unit in %-v Error: %v", repo, err) log.Error("Failed to get the wiki unit in %-v Error: %v", repo, err)
ctx.ServerError("GetUnit(UnitTypeWiki) for "+repo.FullName(), err) ctx.ServerError("GetUnit(UnitTypeWiki) for "+repo.FullName(), err)
return nil return
} }
} }

View File

@ -189,7 +189,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
var issueIDs []int64 var issueIDs []int64
if len(keyword) > 0 { if len(keyword) > 0 {
issueIDs, err = issue_indexer.SearchIssuesByKeyword(ctx, []int64{repo.ID}, keyword, ctx.FormString("state")) issueIDs, err = issue_indexer.SearchIssuesByKeyword(ctx, []int64{repo.ID}, keyword)
if err != nil { if err != nil {
if issue_indexer.IsAvailable(ctx) { if issue_indexer.IsAvailable(ctx) {
ctx.ServerError("issueIndexer.Search", err) ctx.ServerError("issueIndexer.Search", err)
@ -1922,12 +1922,9 @@ func ViewIssue(ctx *context.Context) {
ctx.HTML(http.StatusOK, tplIssueView) ctx.HTML(http.StatusOK, tplIssueView)
} }
// checkBlockedByIssues return canRead and notPermitted
func checkBlockedByIssues(ctx *context.Context, blockers []*issues_model.DependencyInfo) (canRead, notPermitted []*issues_model.DependencyInfo) { func checkBlockedByIssues(ctx *context.Context, blockers []*issues_model.DependencyInfo) (canRead, notPermitted []*issues_model.DependencyInfo) {
var ( var lastRepoID int64
lastRepoID int64 var lastPerm access_model.Permission
lastPerm access_model.Permission
)
for i, blocker := range blockers { for i, blocker := range blockers {
// Get the permissions for this repository // Get the permissions for this repository
perm := lastPerm perm := lastPerm
@ -1939,7 +1936,7 @@ func checkBlockedByIssues(ctx *context.Context, blockers []*issues_model.Depende
perm, err = access_model.GetUserRepoPermission(ctx, &blocker.Repository, ctx.Doer) perm, err = access_model.GetUserRepoPermission(ctx, &blocker.Repository, ctx.Doer)
if err != nil { if err != nil {
ctx.ServerError("GetUserRepoPermission", err) ctx.ServerError("GetUserRepoPermission", err)
return nil, nil return
} }
} }
lastRepoID = blocker.Repository.ID lastRepoID = blocker.Repository.ID
@ -2466,7 +2463,7 @@ func SearchIssues(ctx *context.Context) {
} }
var issueIDs []int64 var issueIDs []int64
if len(keyword) > 0 && len(repoIDs) > 0 { if len(keyword) > 0 && len(repoIDs) > 0 {
if issueIDs, err = issue_indexer.SearchIssuesByKeyword(ctx, repoIDs, keyword, ctx.FormString("state")); err != nil { if issueIDs, err = issue_indexer.SearchIssuesByKeyword(ctx, repoIDs, keyword); err != nil {
ctx.Error(http.StatusInternalServerError, "SearchIssuesByKeyword", err.Error()) ctx.Error(http.StatusInternalServerError, "SearchIssuesByKeyword", err.Error())
return return
} }
@ -2614,7 +2611,7 @@ func ListIssues(ctx *context.Context) {
var issueIDs []int64 var issueIDs []int64
var labelIDs []int64 var labelIDs []int64
if len(keyword) > 0 { if len(keyword) > 0 {
issueIDs, err = issue_indexer.SearchIssuesByKeyword(ctx, []int64{ctx.Repo.Repository.ID}, keyword, ctx.FormString("state")) issueIDs, err = issue_indexer.SearchIssuesByKeyword(ctx, []int64{ctx.Repo.Repository.ID}, keyword)
if err != nil { if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error()) ctx.Error(http.StatusInternalServerError, err.Error())
return return

View File

@ -977,18 +977,6 @@ func renderCode(ctx *context.Context) {
return return
} }
if ctx.Doer != nil {
if err := ctx.Repo.Repository.GetBaseRepo(ctx); err != nil {
ctx.ServerError("GetBaseRepo", err)
return
}
ctx.Data["RecentlyPushedNewBranches"], err = git_model.FindRecentlyPushedNewBranches(ctx, ctx.Repo.Repository.ID, ctx.Doer.ID)
if err != nil {
ctx.ServerError("GetRecentlyPushedBranches", err)
return
}
}
var treeNames []string var treeNames []string
paths := make([]string, 0, 5) paths := make([]string, 0, 5)
if len(ctx.Repo.TreePath) > 0 { if len(ctx.Repo.TreePath) > 0 {

View File

@ -12,6 +12,7 @@ import (
"net/url" "net/url"
"path/filepath" "path/filepath"
"strings" "strings"
"time"
git_model "code.gitea.io/gitea/models/git" git_model "code.gitea.io/gitea/models/git"
repo_model "code.gitea.io/gitea/models/repo" repo_model "code.gitea.io/gitea/models/repo"
@ -670,7 +671,7 @@ func WikiRaw(ctx *context.Context) {
} }
if entry != nil { if entry != nil {
if err = common.ServeBlob(ctx.Base, ctx.Repo.TreePath, entry.Blob(), nil); err != nil { if err = common.ServeBlob(ctx.Base, ctx.Repo.TreePath, entry.Blob(), time.Time{}); err != nil {
ctx.ServerError("ServeBlob", err) ctx.ServerError("ServeBlob", err)
} }
return return

View File

@ -725,7 +725,7 @@ func issueIDsFromSearch(ctx *context.Context, ctxUser *user_model.User, keyword
if err != nil { if err != nil {
return nil, fmt.Errorf("GetRepoIDsForIssuesOptions: %w", err) return nil, fmt.Errorf("GetRepoIDsForIssuesOptions: %w", err)
} }
issueIDsFromSearch, err := issue_indexer.SearchIssuesByKeyword(ctx, searchRepoIDs, keyword, ctx.FormString("state")) issueIDsFromSearch, err := issue_indexer.SearchIssuesByKeyword(ctx, searchRepoIDs, keyword)
if err != nil { if err != nil {
return nil, fmt.Errorf("SearchIssuesByKeyword: %w", err) return nil, fmt.Errorf("SearchIssuesByKeyword: %w", err)
} }

View File

@ -287,9 +287,9 @@ func Action(ctx *context.Context) {
} }
if err != nil { if err != nil {
log.Error("Failed to apply action %q: %v", ctx.FormString("action"), err) ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.FormString("action")), err)
ctx.JSONError(fmt.Sprintf("Action %q failed", ctx.FormString("action")))
return return
} }
ctx.JSONOK() // FIXME: We should check this URL and make sure that it's a valid Gitea URL
ctx.RedirectToFirst(ctx.FormString("redirect_to"), ctx.ContextUser.HomeLink())
} }

View File

@ -1256,20 +1256,20 @@ func registerRoutes(m *web.Route) {
m.Group("/blob_excerpt", func() { m.Group("/blob_excerpt", func() {
m.Get("/{sha}", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.ExcerptBlob) m.Get("/{sha}", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.ExcerptBlob)
}, func(ctx *context.Context) gocontext.CancelFunc { }, func(ctx *context.Context) (cancel gocontext.CancelFunc) {
if ctx.FormBool("wiki") { if ctx.FormBool("wiki") {
ctx.Data["PageIsWiki"] = true ctx.Data["PageIsWiki"] = true
repo.MustEnableWiki(ctx) repo.MustEnableWiki(ctx)
return nil return
} }
reqRepoCodeReader(ctx) reqRepoCodeReader(ctx)
if ctx.Written() { if ctx.Written() {
return nil return
} }
cancel := context.RepoRef()(ctx) cancel = context.RepoRef()(ctx)
if ctx.Written() { if ctx.Written() {
return cancel return
} }
repo.MustBeNotEmpty(ctx) repo.MustBeNotEmpty(ctx)

View File

@ -152,6 +152,7 @@ func notify(ctx context.Context, input *notifyInput) error {
} else { } else {
for _, wf := range workflows { for _, wf := range workflows {
if wf.TriggerEvent != actions_module.GithubEventPullRequestTarget { if wf.TriggerEvent != actions_module.GithubEventPullRequestTarget {
wf.Ref = ref
detectedWorkflows = append(detectedWorkflows, wf) detectedWorkflows = append(detectedWorkflows, wf)
} }
} }
@ -173,6 +174,7 @@ func notify(ctx context.Context, input *notifyInput) error {
} else { } else {
for _, wf := range baseWorkflows { for _, wf := range baseWorkflows {
if wf.TriggerEvent == actions_module.GithubEventPullRequestTarget { if wf.TriggerEvent == actions_module.GithubEventPullRequestTarget {
wf.Ref = baseRef
detectedWorkflows = append(detectedWorkflows, wf) detectedWorkflows = append(detectedWorkflows, wf)
} }
} }
@ -210,8 +212,8 @@ func notify(ctx context.Context, input *notifyInput) error {
OwnerID: input.Repo.OwnerID, OwnerID: input.Repo.OwnerID,
WorkflowID: dwf.EntryName, WorkflowID: dwf.EntryName,
TriggerUserID: input.Doer.ID, TriggerUserID: input.Doer.ID,
Ref: ref, Ref: dwf.Ref,
CommitSHA: commit.ID.String(), CommitSHA: dwf.Commit.ID.String(),
IsForkPullRequest: isForkPullRequest, IsForkPullRequest: isForkPullRequest,
Event: input.Event, Event: input.Event,
EventPayload: string(p), EventPayload: string(p),

View File

@ -90,7 +90,7 @@ func IsUserHiddenCommentTypeGroupChecked(group string, hiddenCommentTypes *big.I
commentTypes, ok := hiddenCommentTypeGroups[group] commentTypes, ok := hiddenCommentTypeGroups[group]
if !ok { if !ok {
log.Critical("the group map for hidden comment types is out of sync, unknown group: %v", group) log.Critical("the group map for hidden comment types is out of sync, unknown group: %v", group)
return false return
} }
if hiddenCommentTypes == nil { if hiddenCommentTypes == nil {
return false return false

View File

@ -779,7 +779,7 @@ func skipToNextDiffHead(input *bufio.Reader) (line string, err error) {
for { for {
lineBytes, isFragment, err = input.ReadLine() lineBytes, isFragment, err = input.ReadLine()
if err != nil { if err != nil {
return "", err return
} }
if wasFragment { if wasFragment {
wasFragment = isFragment wasFragment = isFragment
@ -795,7 +795,7 @@ func skipToNextDiffHead(input *bufio.Reader) (line string, err error) {
var tail string var tail string
tail, err = input.ReadString('\n') tail, err = input.ReadString('\n')
if err != nil { if err != nil {
return "", err return
} }
line += tail line += tail
} }
@ -821,21 +821,22 @@ func parseHunks(curFile *DiffFile, maxLines, maxLineCharacters int, input *bufio
_, isFragment, err = input.ReadLine() _, isFragment, err = input.ReadLine()
if err != nil { if err != nil {
// Now by the definition of ReadLine this cannot be io.EOF // Now by the definition of ReadLine this cannot be io.EOF
return nil, false, fmt.Errorf("unable to ReadLine: %w", err) err = fmt.Errorf("unable to ReadLine: %w", err)
return
} }
} }
sb.Reset() sb.Reset()
lineBytes, isFragment, err = input.ReadLine() lineBytes, isFragment, err = input.ReadLine()
if err != nil { if err != nil {
if err == io.EOF { if err == io.EOF {
return lineBytes, isFragment, err return
} }
err = fmt.Errorf("unable to ReadLine: %w", err) err = fmt.Errorf("unable to ReadLine: %w", err)
return nil, false, err return
} }
if lineBytes[0] == 'd' { if lineBytes[0] == 'd' {
// End of hunks // End of hunks
return lineBytes, isFragment, err return
} }
switch lineBytes[0] { switch lineBytes[0] {
@ -852,7 +853,8 @@ func parseHunks(curFile *DiffFile, maxLines, maxLineCharacters int, input *bufio
lineBytes, isFragment, err = input.ReadLine() lineBytes, isFragment, err = input.ReadLine()
if err != nil { if err != nil {
// Now by the definition of ReadLine this cannot be io.EOF // Now by the definition of ReadLine this cannot be io.EOF
return nil, false, fmt.Errorf("unable to ReadLine: %w", err) err = fmt.Errorf("unable to ReadLine: %w", err)
return
} }
_, _ = sb.Write(lineBytes) _, _ = sb.Write(lineBytes)
} }
@ -882,7 +884,8 @@ func parseHunks(curFile *DiffFile, maxLines, maxLineCharacters int, input *bufio
} }
// This is used only to indicate that the current file does not have a terminal newline // This is used only to indicate that the current file does not have a terminal newline
if !bytes.Equal(lineBytes, []byte("\\ No newline at end of file")) { if !bytes.Equal(lineBytes, []byte("\\ No newline at end of file")) {
return nil, false, fmt.Errorf("unexpected line in hunk: %s", string(lineBytes)) err = fmt.Errorf("unexpected line in hunk: %s", string(lineBytes))
return
} }
// Technically this should be the end the file! // Technically this should be the end the file!
// FIXME: we should be putting a marker at the end of the file if there is no terminal new line // FIXME: we should be putting a marker at the end of the file if there is no terminal new line
@ -950,7 +953,8 @@ func parseHunks(curFile *DiffFile, maxLines, maxLineCharacters int, input *bufio
curSection.Lines = append(curSection.Lines, diffLine) curSection.Lines = append(curSection.Lines, diffLine)
default: default:
// This is unexpected // This is unexpected
return nil, false, fmt.Errorf("unexpected line in hunk: %s", string(lineBytes)) err = fmt.Errorf("unexpected line in hunk: %s", string(lineBytes))
return
} }
line := string(lineBytes) line := string(lineBytes)
@ -961,7 +965,8 @@ func parseHunks(curFile *DiffFile, maxLines, maxLineCharacters int, input *bufio
lineBytes, isFragment, err = input.ReadLine() lineBytes, isFragment, err = input.ReadLine()
if err != nil { if err != nil {
// Now by the definition of ReadLine this cannot be io.EOF // Now by the definition of ReadLine this cannot be io.EOF
return lineBytes, isFragment, fmt.Errorf("unable to ReadLine: %w", err) err = fmt.Errorf("unable to ReadLine: %w", err)
return
} }
} }
} }

View File

@ -46,12 +46,13 @@ func DeleteNotPassedAssignee(ctx context.Context, issue *issues_model.Issue, doe
func ToggleAssignee(ctx context.Context, issue *issues_model.Issue, doer *user_model.User, assigneeID int64) (removed bool, comment *issues_model.Comment, err error) { func ToggleAssignee(ctx context.Context, issue *issues_model.Issue, doer *user_model.User, assigneeID int64) (removed bool, comment *issues_model.Comment, err error) {
removed, comment, err = issues_model.ToggleIssueAssignee(ctx, issue, doer, assigneeID) removed, comment, err = issues_model.ToggleIssueAssignee(ctx, issue, doer, assigneeID)
if err != nil { if err != nil {
return false, nil, err return
} }
assignee, err := user_model.GetUserByID(ctx, assigneeID) assignee, err1 := user_model.GetUserByID(ctx, assigneeID)
if err != nil { if err1 != nil {
return false, nil, err err = err1
return
} }
notification.NotifyIssueChangeAssignee(ctx, doer, issue, assignee, removed, comment) notification.NotifyIssueChangeAssignee(ctx, doer, issue, assignee, removed, comment)
@ -235,23 +236,23 @@ func TeamReviewRequest(ctx context.Context, issue *issues_model.Issue, doer *use
} }
if err != nil { if err != nil {
return nil, err return
} }
if comment == nil || !isAdd { if comment == nil || !isAdd {
return nil, nil return
} }
// notify all user in this team // notify all user in this team
if err := comment.LoadIssue(ctx); err != nil { if err = comment.LoadIssue(ctx); err != nil {
return nil, err return
} }
members, err := organization.GetTeamMembers(ctx, &organization.SearchMembersOptions{ members, err := organization.GetTeamMembers(ctx, &organization.SearchMembersOptions{
TeamID: reviewer.ID, TeamID: reviewer.ID,
}) })
if err != nil { if err != nil {
return nil, err return
} }
for _, member := range members { for _, member := range members {

View File

@ -49,17 +49,17 @@ func NewIssue(ctx context.Context, repo *repo_model.Repository, issue *issues_mo
} }
// ChangeTitle changes the title of this issue, as the given user. // ChangeTitle changes the title of this issue, as the given user.
func ChangeTitle(ctx context.Context, issue *issues_model.Issue, doer *user_model.User, title string) error { func ChangeTitle(ctx context.Context, issue *issues_model.Issue, doer *user_model.User, title string) (err error) {
oldTitle := issue.Title oldTitle := issue.Title
issue.Title = title issue.Title = title
if err := issues_model.ChangeIssueTitle(ctx, issue, doer, oldTitle); err != nil { if err = issues_model.ChangeIssueTitle(ctx, issue, doer, oldTitle); err != nil {
return err return
} }
if issue.IsPull && issues_model.HasWorkInProgressPrefix(oldTitle) && !issues_model.HasWorkInProgressPrefix(title) { if issue.IsPull && issues_model.HasWorkInProgressPrefix(oldTitle) && !issues_model.HasWorkInProgressPrefix(title) {
if err := issues_model.PullRequestCodeOwnersReview(ctx, issue, issue.PullRequest); err != nil { if err = issues_model.PullRequestCodeOwnersReview(ctx, issue, issue.PullRequest); err != nil {
return err return
} }
} }

View File

@ -12,9 +12,9 @@ import (
) )
// ClearLabels clears all of an issue's labels // ClearLabels clears all of an issue's labels
func ClearLabels(issue *issues_model.Issue, doer *user_model.User) error { func ClearLabels(issue *issues_model.Issue, doer *user_model.User) (err error) {
if err := issues_model.ClearIssueLabels(issue, doer); err != nil { if err = issues_model.ClearIssueLabels(issue, doer); err != nil {
return err return
} }
notification.NotifyIssueClearLabels(db.DefaultContext, doer, issue) notification.NotifyIssueClearLabels(db.DefaultContext, doer, issue)

View File

@ -320,7 +320,7 @@ func SubmitReview(ctx context.Context, doer *user_model.User, gitRepo *git.Repos
func DismissReview(ctx context.Context, reviewID, repoID int64, message string, doer *user_model.User, isDismiss, dismissPriors bool) (comment *issues_model.Comment, err error) { func DismissReview(ctx context.Context, reviewID, repoID int64, message string, doer *user_model.User, isDismiss, dismissPriors bool) (comment *issues_model.Comment, err error) {
review, err := issues_model.GetReviewByID(ctx, reviewID) review, err := issues_model.GetReviewByID(ctx, reviewID)
if err != nil { if err != nil {
return nil, err return
} }
if review.Type != issues_model.ReviewTypeApprove && review.Type != issues_model.ReviewTypeReject { if review.Type != issues_model.ReviewTypeApprove && review.Type != issues_model.ReviewTypeReject {
@ -328,7 +328,7 @@ func DismissReview(ctx context.Context, reviewID, repoID int64, message string,
} }
// load data for notify // load data for notify
if err := review.LoadAttributes(ctx); err != nil { if err = review.LoadAttributes(ctx); err != nil {
return nil, err return nil, err
} }
@ -337,8 +337,8 @@ func DismissReview(ctx context.Context, reviewID, repoID int64, message string,
return nil, fmt.Errorf("reviews's repository is not the same as the one we expect") return nil, fmt.Errorf("reviews's repository is not the same as the one we expect")
} }
if err := issues_model.DismissReview(review, isDismiss); err != nil { if err = issues_model.DismissReview(review, isDismiss); err != nil {
return nil, err return
} }
if dismissPriors { if dismissPriors {
@ -361,11 +361,11 @@ func DismissReview(ctx context.Context, reviewID, repoID int64, message string,
return nil, nil return nil, nil
} }
if err := review.Issue.LoadPullRequest(ctx); err != nil { if err = review.Issue.LoadPullRequest(ctx); err != nil {
return nil, err return
} }
if err := review.Issue.LoadAttributes(ctx); err != nil { if err = review.Issue.LoadAttributes(ctx); err != nil {
return nil, err return
} }
comment, err = issue_service.CreateComment(ctx, &issues_model.CreateCommentOptions{ comment, err = issue_service.CreateComment(ctx, &issues_model.CreateCommentOptions{
@ -377,7 +377,7 @@ func DismissReview(ctx context.Context, reviewID, repoID int64, message string,
Repo: review.Issue.Repo, Repo: review.Issue.Repo,
}) })
if err != nil { if err != nil {
return nil, err return
} }
comment.Review = review comment.Review = review
@ -386,5 +386,5 @@ func DismissReview(ctx context.Context, reviewID, repoID int64, message string,
notification.NotifyPullReviewDismiss(ctx, doer, review, comment) notification.NotifyPullReviewDismiss(ctx, doer, review, comment)
return comment, nil return comment, err
} }

View File

@ -187,7 +187,7 @@ func CreateNewTag(ctx context.Context, doer *user_model.User, repo *repo_model.R
// editAttachments accept a map of attachment uuid to new attachment name which will be updated with attachments. // editAttachments accept a map of attachment uuid to new attachment name which will be updated with attachments.
func UpdateRelease(doer *user_model.User, gitRepo *git.Repository, rel *repo_model.Release, func UpdateRelease(doer *user_model.User, gitRepo *git.Repository, rel *repo_model.Release,
addAttachmentUUIDs, delAttachmentUUIDs []string, editAttachments map[string]string, addAttachmentUUIDs, delAttachmentUUIDs []string, editAttachments map[string]string,
) error { ) (err error) {
if rel.ID == 0 { if rel.ID == 0 {
return errors.New("UpdateRelease only accepts an exist release") return errors.New("UpdateRelease only accepts an exist release")
} }
@ -264,8 +264,8 @@ func UpdateRelease(doer *user_model.User, gitRepo *git.Repository, rel *repo_mod
} }
} }
if err := committer.Commit(); err != nil { if err = committer.Commit(); err != nil {
return err return
} }
for _, uuid := range delAttachmentUUIDs { for _, uuid := range delAttachmentUUIDs {
@ -280,14 +280,14 @@ func UpdateRelease(doer *user_model.User, gitRepo *git.Repository, rel *repo_mod
if !isCreated { if !isCreated {
notification.NotifyUpdateRelease(gitRepo.Ctx, doer, rel) notification.NotifyUpdateRelease(gitRepo.Ctx, doer, rel)
return nil return
} }
if !rel.IsDraft { if !rel.IsDraft {
notification.NotifyNewRelease(gitRepo.Ctx, rel) notification.NotifyNewRelease(gitRepo.Ctx, rel)
} }
return nil return err
} }
// DeleteReleaseByID deletes a release and corresponding Git tag by given ID. // DeleteReleaseByID deletes a release and corresponding Git tag by given ID.

View File

@ -20,13 +20,16 @@
</div> </div>
</div> </div>
<div class="right menu"> <div class="right menu">
<button class="link-action ui basic button gt-mr-0" data-url="{{.Org.HomeLink}}?action={{if $.IsFollowing}}unfollow{{else}}follow{{end}}"> <form method="post" action="{{.Link}}?action={{if $.IsFollowing}}unfollow{{else}}follow{{end}}&redirect_to={{$.Link}}">
{{$.CsrfTokenHtml}}
<button type="submit" class="ui basic button gt-mr-0">
{{if $.IsFollowing}} {{if $.IsFollowing}}
{{.locale.Tr "user.unfollow"}} {{.locale.Tr "user.unfollow"}}
{{else}} {{else}}
{{.locale.Tr "user.follow"}} {{.locale.Tr "user.follow"}}
{{end}} {{end}}
</button> </button>
</form>
</div> </div>
</div> </div>

View File

@ -1,5 +1,5 @@
{{template "base/head" .}} {{template "base/head" .}}
<div role="main" aria-label="{{.Title}}" class="page-content repository projects view-project"> <div role="main" aria-label="{{.Title}}" class="page-content repository packages">
{{template "shared/user/org_profile_avatar" .}} {{template "shared/user/org_profile_avatar" .}}
<div class="ui container"> <div class="ui container">
{{template "user/overview/header" .}} {{template "user/overview/header" .}}

View File

@ -18,7 +18,7 @@
</div> </div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "Alpine" "https://docs.gitea.io/en-us/usage/packages/alpine/" | Safe}}</label> <label>{{.locale.Tr "packages.alpine.documentation" "https://docs.gitea.io/en-us/packages/alpine/" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -18,7 +18,7 @@ git-fetch-with-cli = true</code></pre></div>
<div class="markup"><pre class="code-block"><code>cargo add {{.PackageDescriptor.Package.Name}}@{{.PackageDescriptor.Version.Version}}</code></pre></div> <div class="markup"><pre class="code-block"><code>cargo add {{.PackageDescriptor.Package.Name}}@{{.PackageDescriptor.Version.Version}}</code></pre></div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "Cargo" "https://docs.gitea.io/en-us/usage/packages/cargo/" | Safe}}</label> <label>{{.locale.Tr "packages.cargo.documentation" "https://docs.gitea.io/en-us/usage/packages/cargo/" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -11,7 +11,7 @@
<div class="markup"><pre class="code-block"><code>knife supermarket install {{.PackageDescriptor.Package.Name}} {{.PackageDescriptor.Version.Version}}</code></pre></div> <div class="markup"><pre class="code-block"><code>knife supermarket install {{.PackageDescriptor.Package.Name}} {{.PackageDescriptor.Version.Version}}</code></pre></div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "Chef" "https://docs.gitea.io/en-us/usage/packages/chef/" | Safe}}</label> <label>{{.locale.Tr "packages.chef.documentation" "https://docs.gitea.io/en-us/usage/packages/chef/" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -17,7 +17,7 @@
<div class="markup"><pre class="code-block"><code>composer require {{.PackageDescriptor.Package.Name}}:{{.PackageDescriptor.Version.Version}}</code></pre></div> <div class="markup"><pre class="code-block"><code>composer require {{.PackageDescriptor.Package.Name}}:{{.PackageDescriptor.Version.Version}}</code></pre></div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "Composer" "https://docs.gitea.io/en-us/usage/packages/composer/" | Safe}}</label> <label>{{.locale.Tr "packages.composer.documentation" "https://docs.gitea.io/en-us/usage/packages/composer/" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -11,7 +11,7 @@
<div class="markup"><pre class="code-block"><code>conan install --remote=gitea {{.PackageDescriptor.Package.Name}}/{{.PackageDescriptor.Version.Version}}</code></pre></div> <div class="markup"><pre class="code-block"><code>conan install --remote=gitea {{.PackageDescriptor.Package.Name}}/{{.PackageDescriptor.Version.Version}}</code></pre></div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "Conan" "https://docs.gitea.io/en-us/usage/packages/conan/" | Safe}}</label> <label>{{.locale.Tr "packages.conan.documentation" "https://docs.gitea.io/en-us/usage/packages/conan/" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -16,7 +16,7 @@ default_channels:
<div class="markup"><pre class="code-block"><code>conda install{{if $channel}} -c {{$channel}}{{end}} {{.PackageDescriptor.PackageProperties.GetByName "conda.name"}}={{.PackageDescriptor.Version.Version}}</code></pre></div> <div class="markup"><pre class="code-block"><code>conda install{{if $channel}} -c {{$channel}}{{end}} {{.PackageDescriptor.PackageProperties.GetByName "conda.name"}}={{.PackageDescriptor.Version.Version}}</code></pre></div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "Conda" "https://docs.gitea.io/en-us/usage/packages/conda/" | Safe}}</label> <label>{{.locale.Tr "packages.conda.documentation" "https://docs.gitea.io/en-us/usage/packages/conda/" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -19,7 +19,7 @@
<div class="markup"><pre class="code-block"><code>{{range .PackageDescriptor.Files}}{{if eq .File.LowerName "manifest.json"}}{{.Properties.GetByName "container.digest"}}{{end}}{{end}}</code></pre></div> <div class="markup"><pre class="code-block"><code>{{range .PackageDescriptor.Files}}{{if eq .File.LowerName "manifest.json"}}{{.Properties.GetByName "container.digest"}}{{end}}{{end}}</code></pre></div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "Container" "https://docs.gitea.io/en-us/usage/packages/container/" | Safe}}</label> <label>{{.locale.Tr "packages.container.documentation" "https://docs.gitea.io/en-us/usage/packages/container/" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -11,7 +11,7 @@
<div class="markup"><pre class="code-block"><code>install.packages("{{.PackageDescriptor.Package.Name}}")</code></pre></div> <div class="markup"><pre class="code-block"><code>install.packages("{{.PackageDescriptor.Package.Name}}")</code></pre></div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "CRAN" "https://docs.gitea.io/en-us/usage/packages/container/" | Safe}}</label> <label>{{.locale.Tr "packages.cran.documentation" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -16,7 +16,7 @@ sudo apt update</code></pre></div>
</div> </div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "Debian" "https://docs.gitea.io/en-us/usage/packages/debian/" | Safe}}</label> <label>{{.locale.Tr "packages.debian.documentation" "https://docs.gitea.io/en-us/packages/debian/" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -11,7 +11,7 @@ curl <gitea-origin-url data-url="{{AppSubUrl}}/api/packages/{{$.PackageDescripto
</code></pre></div> </code></pre></div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "Generic" "https://docs.gitea.io/en-us/usage/packages/generic" | Safe}}</label> <label>{{.locale.Tr "packages.generic.documentation" "https://docs.gitea.io/en-us/usage/packages/generic" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -7,7 +7,7 @@
<div class="markup"><pre class="code-block"><code>GOPROXY=<gitea-origin-url data-url="{{AppSubUrl}}/api/packages/{{$.PackageDescriptor.Owner.Name}}/go"></gitea-origin-url> go install {{$.PackageDescriptor.Package.Name}}@{{$.PackageDescriptor.Version.Version}}</code></pre></div> <div class="markup"><pre class="code-block"><code>GOPROXY=<gitea-origin-url data-url="{{AppSubUrl}}/api/packages/{{$.PackageDescriptor.Owner.Name}}/go"></gitea-origin-url> go install {{$.PackageDescriptor.Package.Name}}@{{$.PackageDescriptor.Version.Version}}</code></pre></div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "Go" "https://docs.gitea.io/en-us/usage/packages/go" | Safe}}</label> <label>{{.locale.Tr "packages.go.documentation" "https://docs.gitea.io/en-us/usage/packages/go" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -12,7 +12,7 @@ helm repo update</code></pre></div>
<div class="markup"><pre class="code-block"><code>helm install {{.PackageDescriptor.Package.Name}} {{AppDomain}}/{{.PackageDescriptor.Package.Name}}</code></pre></div> <div class="markup"><pre class="code-block"><code>helm install {{.PackageDescriptor.Package.Name}} {{AppDomain}}/{{.PackageDescriptor.Package.Name}}</code></pre></div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "Helm" "https://docs.gitea.io/en-us/usage/packages/helm/" | Safe}}</label> <label>{{.locale.Tr "packages.helm.documentation" "https://docs.gitea.io/en-us/usage/packages/helm/" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -40,7 +40,7 @@
<div class="markup"><pre class="code-block"><code>mvn dependency:get -DremoteRepositories=<gitea-origin-url data-url="{{AppSubUrl}}/api/packages/{{.PackageDescriptor.Owner.Name}}/maven"></gitea-origin-url> -Dartifact={{.PackageDescriptor.Metadata.GroupID}}:{{.PackageDescriptor.Metadata.ArtifactID}}:{{.PackageDescriptor.Version.Version}}</code></pre></div> <div class="markup"><pre class="code-block"><code>mvn dependency:get -DremoteRepositories=<gitea-origin-url data-url="{{AppSubUrl}}/api/packages/{{.PackageDescriptor.Owner.Name}}/maven"></gitea-origin-url> -Dartifact={{.PackageDescriptor.Metadata.GroupID}}:{{.PackageDescriptor.Metadata.ArtifactID}}:{{.PackageDescriptor.Version.Version}}</code></pre></div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "Maven" "https://docs.gitea.io/en-us/usage/packages/maven/" | Safe}}</label> <label>{{.locale.Tr "packages.maven.documentation" "https://docs.gitea.io/en-us/usage/packages/maven/" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -15,7 +15,7 @@
<div class="markup"><pre class="code-block"><code>&quot;{{.PackageDescriptor.Package.Name}}&quot;: &quot;{{.PackageDescriptor.Version.Version}}&quot;</code></pre></div> <div class="markup"><pre class="code-block"><code>&quot;{{.PackageDescriptor.Package.Name}}&quot;: &quot;{{.PackageDescriptor.Version.Version}}&quot;</code></pre></div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "npm" "https://docs.gitea.io/en-us/usage/packages/npm/" | Safe}}</label> <label>{{.locale.Tr "packages.npm.documentation" "https://docs.gitea.io/en-us/usage/packages/npm/" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -11,7 +11,7 @@
<div class="markup"><pre class="code-block"><code>dotnet add package --source {{.PackageDescriptor.Owner.Name}} --version {{.PackageDescriptor.Version.Version}} {{.PackageDescriptor.Package.Name}}</code></pre></div> <div class="markup"><pre class="code-block"><code>dotnet add package --source {{.PackageDescriptor.Owner.Name}} --version {{.PackageDescriptor.Version.Version}} {{.PackageDescriptor.Package.Name}}</code></pre></div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "NuGet" "https://docs.gitea.io/en-us/usage/packages/nuget/" | Safe}}</label> <label>{{.locale.Tr "packages.nuget.documentation" "https://docs.gitea.io/en-us/usage/packages/nuget/" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -7,7 +7,7 @@
<div class="markup"><pre class="code-block"><code>dart pub add {{.PackageDescriptor.Package.Name}}:{{.PackageDescriptor.Version.Version}} --hosted-url=<gitea-origin-url data-url="{{AppSubUrl}}/api/packages/{{.PackageDescriptor.Owner.Name}}/pub/"></gitea-origin-url></code></pre></div> <div class="markup"><pre class="code-block"><code>dart pub add {{.PackageDescriptor.Package.Name}}:{{.PackageDescriptor.Version.Version}} --hosted-url=<gitea-origin-url data-url="{{AppSubUrl}}/api/packages/{{.PackageDescriptor.Owner.Name}}/pub/"></gitea-origin-url></code></pre></div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "Pub" "https://docs.gitea.io/en-us/usage/packages/pub/" | Safe}}</label> <label>{{.locale.Tr "packages.pub.documentation" "https://docs.gitea.io/en-us/usage/packages/pub/" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -7,7 +7,7 @@
<div class="markup"><pre class="code-block"><code>pip install --index-url <gitea-origin-url data-url="{{AppSubUrl}}/api/packages/{{.PackageDescriptor.Owner.Name}}/pypi/simple/"></gitea-origin-url> {{.PackageDescriptor.Package.Name}}</code></pre></div> <div class="markup"><pre class="code-block"><code>pip install --index-url <gitea-origin-url data-url="{{AppSubUrl}}/api/packages/{{.PackageDescriptor.Owner.Name}}/pypi/simple/"></gitea-origin-url> {{.PackageDescriptor.Package.Name}}</code></pre></div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "PyPI" "https://docs.gitea.io/en-us/usage/packages/pypi/" | Safe}}</label> <label>{{.locale.Tr "packages.pypi.documentation" "https://docs.gitea.io/en-us/usage/packages/pypi/" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -13,7 +13,7 @@
</div> </div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "RPM" "https://docs.gitea.io/en-us/usage/packages/rpm/" | Safe}}</label> <label>{{.locale.Tr "packages.rpm.documentation" "https://docs.gitea.io/en-us/usage/packages/rpm/" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -13,7 +13,7 @@
end</code></pre></div> end</code></pre></div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "RubyGems" "https://docs.gitea.io/en-us/usage/packages/rubygems/" | Safe}}</label> <label>{{.locale.Tr "packages.rubygems.documentation" "https://docs.gitea.io/en-us/usage/packages/rubygems/" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -17,7 +17,7 @@
<div class="markup"><pre class="code-block"><code>swift package resolve</code></pre></div> <div class="markup"><pre class="code-block"><code>swift package resolve</code></pre></div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "Swift" "https://docs.gitea.io/en-us/usage/packages/swift/" | Safe}}</label> <label>{{.locale.Tr "packages.swift.documentation" "https://docs.gitea.io/en-us/usage/packages/swift/" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -7,7 +7,7 @@
<div class="markup"><pre class="code-block"><code>vagrant box add --box-version {{.PackageDescriptor.Version.Version}} "<gitea-origin-url data-url="{{AppSubUrl}}/api/packages/{{.PackageDescriptor.Owner.Name}}/vagrant/{{.PackageDescriptor.Package.Name}}"></gitea-origin-url>"</code></pre></div> <div class="markup"><pre class="code-block"><code>vagrant box add --box-version {{.PackageDescriptor.Version.Version}} "<gitea-origin-url data-url="{{AppSubUrl}}/api/packages/{{.PackageDescriptor.Owner.Name}}/vagrant/{{.PackageDescriptor.Package.Name}}"></gitea-origin-url>"</code></pre></div>
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "Vagrant" "https://docs.gitea.io/en-us/usage/packages/vagrant/" | Safe}}</label> <label>{{.locale.Tr "packages.vagrant.documentation" "https://docs.gitea.io/en-us/usage/packages/vagrant/" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -18,7 +18,7 @@
<button class="ui green button">{{$.locale.Tr "packages.owner.settings.cargo.rebuild"}}</button> <button class="ui green button">{{$.locale.Tr "packages.owner.settings.cargo.rebuild"}}</button>
</form> </form>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "Cargo" "https://docs.gitea.io/en-us/usage/packages/cargo/" | Safe}}</label> <label>{{.locale.Tr "packages.cargo.documentation" "https://docs.gitea.io/en-us/usage/packages/cargo/" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,5 +1,5 @@
{{template "base/alert" .}} {{template "base/alert" .}}
<form class="ui form ignore-dirty"> <form class="ui form ignore-dirty">
<div class="ui fluid action input"> <div class="ui fluid action input">
{{template "shared/searchinput" dict "locale" .locale "Value" .Query "AutoFocus" true}} {{template "shared/searchinput" dict "locale" .locale "Value" .Query "AutoFocus" true}}
<select class="ui dropdown" name="type"> <select class="ui dropdown" name="type">
@ -11,8 +11,8 @@
</select> </select>
<button class="ui primary button">{{.locale.Tr "explore.search"}}</button> <button class="ui primary button">{{.locale.Tr "explore.search"}}</button>
</div> </div>
</form> </form>
<div class="ui {{if .PackageDescriptors}}issue list{{end}}"> <div class="ui {{if .PackageDescriptors}}issue list{{end}}">
{{range .PackageDescriptors}} {{range .PackageDescriptors}}
<li class="item gt-df gt-py-3"> <li class="item gt-df gt-py-3">
<div class="issue-item-main"> <div class="issue-item-main">
@ -50,4 +50,4 @@
{{end}} {{end}}
{{end}} {{end}}
{{template "base/paginate" .}} {{template "base/paginate" .}}
</div> </div>

View File

@ -1,5 +1,5 @@
<p><a href="{{.PackageDescriptor.PackageWebLink}}">{{.PackageDescriptor.Package.Name}}</a> / <strong>{{.locale.Tr "packages.versions"}}</strong></p> <p><a href="{{.PackageDescriptor.PackageWebLink}}">{{.PackageDescriptor.Package.Name}}</a> / <strong>{{.locale.Tr "packages.versions"}}</strong></p>
<form class="ui form ignore-dirty"> <form class="ui form ignore-dirty">
<div class="ui fluid action input"> <div class="ui fluid action input">
{{template "shared/searchinput" dict "locale" .locale "Value" .Query "AutoFocus" true}} {{template "shared/searchinput" dict "locale" .locale "Value" .Query "AutoFocus" true}}
<select class="ui dropdown" name="sort"> <select class="ui dropdown" name="sort">
@ -17,8 +17,8 @@
{{end}} {{end}}
<button class="ui primary button">{{.locale.Tr "explore.search"}}</button> <button class="ui primary button">{{.locale.Tr "explore.search"}}</button>
</div> </div>
</form> </form>
<div class="ui {{if .PackageDescriptors}}issue list{{end}}"> <div class="ui {{if .PackageDescriptors}}issue list{{end}}">
{{range .PackageDescriptors}} {{range .PackageDescriptors}}
<li class="item gt-df gt-py-3"> <li class="item gt-df gt-py-3">
<div class="issue-item-main"> <div class="issue-item-main">
@ -34,4 +34,4 @@
<p>{{.locale.Tr "packages.filter.no_result"}}</p> <p>{{.locale.Tr "packages.filter.no_result"}}</p>
{{end}} {{end}}
{{template "base/paginate" .}} {{template "base/paginate" .}}
</div> </div>

View File

@ -1,12 +1,12 @@
{{if .CanWriteProjects}} {{if .CanWriteProjects}}
<div class="gt-tr"> <div class="gt-tr">
<a class="ui small green button" href="{{$.Link}}/new">{{.locale.Tr "repo.projects.new"}}</a> <a class="ui small green button" href="{{$.Link}}/new">{{.locale.Tr "repo.projects.new"}}</a>
</div> </div>
<div class="divider"></div> <div class="divider"></div>
{{end}} {{end}}
{{template "base/alert" .}} {{template "base/alert" .}}
<div class="small-menu-items ui compact tiny menu"> <div class="small-menu-items ui compact tiny menu">
<a class="item{{if not .IsShowClosed}} active{{end}}" href="{{$.Link}}?state=open"> <a class="item{{if not .IsShowClosed}} active{{end}}" href="{{$.Link}}?state=open">
{{svg "octicon-project-symlink" 16 "gt-mr-3"}} {{svg "octicon-project-symlink" 16 "gt-mr-3"}}
{{.locale.PrettyNumber .OpenCount}}&nbsp;{{.locale.Tr "repo.issues.open_title"}} {{.locale.PrettyNumber .OpenCount}}&nbsp;{{.locale.Tr "repo.issues.open_title"}}
@ -15,9 +15,9 @@
{{svg "octicon-check" 16 "gt-mr-3"}} {{svg "octicon-check" 16 "gt-mr-3"}}
{{.locale.PrettyNumber .ClosedCount}}&nbsp;{{.locale.Tr "repo.issues.closed_title"}} {{.locale.PrettyNumber .ClosedCount}}&nbsp;{{.locale.Tr "repo.issues.closed_title"}}
</a> </a>
</div> </div>
<div class="ui right floated secondary filter menu"> <div class="ui right floated secondary filter menu">
<!-- Sort --> <!-- Sort -->
<div class="ui dropdown type jump item"> <div class="ui dropdown type jump item">
<span class="text"> <span class="text">
@ -30,8 +30,8 @@
<a class="{{if eq .SortType "leastupdate"}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&sort=leastupdate&state={{$.State}}">{{.locale.Tr "repo.issues.filter_sort.leastupdate"}}</a> <a class="{{if eq .SortType "leastupdate"}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&sort=leastupdate&state={{$.State}}">{{.locale.Tr "repo.issues.filter_sort.leastupdate"}}</a>
</div> </div>
</div> </div>
</div> </div>
<div class="milestone-list"> <div class="milestone-list">
{{range .Projects}} {{range .Projects}}
<li class="milestone-card"> <li class="milestone-card">
<h3 class="flex-text-block gt-m-0"> <h3 class="flex-text-block gt-m-0">
@ -70,7 +70,7 @@
{{end}} {{end}}
{{template "base/paginate" .}} {{template "base/paginate" .}}
</div> </div>
{{if $.CanWriteProjects}} {{if $.CanWriteProjects}}
<div class="ui g-modal-confirm delete modal"> <div class="ui g-modal-confirm delete modal">

View File

@ -1,4 +1,4 @@
<h2 class="ui dividing header"> <h2 class="ui dividing header">
{{if .PageIsEditProjects}} {{if .PageIsEditProjects}}
{{.locale.Tr "repo.projects.edit"}} {{.locale.Tr "repo.projects.edit"}}
<div class="sub header">{{.locale.Tr "repo.projects.edit_subheader"}}</div> <div class="sub header">{{.locale.Tr "repo.projects.edit_subheader"}}</div>
@ -6,9 +6,9 @@
{{.locale.Tr "repo.projects.new"}} {{.locale.Tr "repo.projects.new"}}
<div class="sub header">{{.locale.Tr "repo.projects.new_subheader"}}</div> <div class="sub header">{{.locale.Tr "repo.projects.new_subheader"}}</div>
{{end}} {{end}}
</h2> </h2>
{{template "base/alert" .}} {{template "base/alert" .}}
<form class="ui form grid" action="{{.Link}}" method="post"> <form class="ui form grid" action="{{.Link}}" method="post">
{{.CsrfTokenHtml}} {{.CsrfTokenHtml}}
<div class="eleven wide column"> <div class="eleven wide column">
<input type="hidden" id="redirect" name="redirect" value="{{.redirect}}"> <input type="hidden" id="redirect" name="redirect" value="{{.redirect}}">
@ -63,4 +63,4 @@
{{if .PageIsEditProjects}}{{.locale.Tr "repo.projects.modify"}}{{else}}{{.locale.Tr "repo.projects.create"}}{{end}} {{if .PageIsEditProjects}}{{.locale.Tr "repo.projects.modify"}}{{else}}{{.locale.Tr "repo.projects.create"}}{{end}}
</button> </button>
</div> </div>
</form> </form>

View File

@ -1,4 +1,6 @@
<div class="ui two column stackable grid"> <div role="main" aria-label="{{.Title}}" class="page-content repository projects view-project">
<div class="ui container">
<div class="ui two column stackable grid">
<div class="column"> <div class="column">
</div> </div>
<div class="column right aligned"> <div class="column right aligned">
@ -34,9 +36,9 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="divider"></div> <div class="divider"></div>
<div class="ui two column stackable grid"> <div class="ui two column stackable grid">
<div class="column"> <div class="column">
<h2 class="project-title">{{$.Project.Title}}</h2> <h2 class="project-title">{{$.Project.Title}}</h2>
<div class="content project-description">{{$.Project.RenderedContent|Str2html}}</div> <div class="content project-description">{{$.Project.RenderedContent|Str2html}}</div>
@ -66,13 +68,14 @@
</div> </div>
</div> </div>
{{end}} {{end}}
</div> </div>
<div class="divider"></div>
</div>
<div class="ui container fluid padded" id="project-board">
<div class="divider"></div>
<div id="project-board">
<div class="board {{if .CanWriteProjects}}sortable{{end}}"> <div class="board {{if .CanWriteProjects}}sortable{{end}}">
{{range $board := .Boards}} {{range $board := .Boards}}
<div class="ui segment board-column" style="background: {{.Color}} !important;" data-id="{{.ID}}" data-sorting="{{.Sorting}}" data-url="{{$.Link}}/{{.ID}}"> <div class="ui segment board-column" style="background: {{.Color}} !important;" data-id="{{.ID}}" data-sorting="{{.Sorting}}" data-url="{{$.Link}}/{{.ID}}">
<div class="board-column-header gt-df gt-ac gt-sb"> <div class="board-column-header gt-df gt-ac gt-sb">
<div class="ui large label board-label gt-py-2"> <div class="ui large label board-label gt-py-2">
@ -248,6 +251,8 @@
{{end}} {{end}}
</div> </div>
</div>
</div> </div>
{{if .CanWriteProjects}} {{if .CanWriteProjects}}

View File

@ -1,11 +0,0 @@
{{range .RecentlyPushedNewBranches}}
<div class="ui positive message gt-df gt-ac">
<div class="gt-f1">
{{$timeSince := TimeSince .UpdatedUnix.AsTime $.locale}}
{{$.locale.Tr "repo.pulls.recently_pushed_new_branches" (PathEscapeSegments .Name) $timeSince | Safe}}
</div>
<a aria-role="button" class="ui compact positive button gt-m-0" href="{{$.Repository.ComposeBranchCompareURL $.Repository.BaseRepo (PathEscapeSegments .Name)}}">
{{$.locale.Tr "repo.pulls.compare_changes"}}
</a>
</div>
{{end}}

View File

@ -3,7 +3,6 @@
{{template "repo/header" .}} {{template "repo/header" .}}
<div class="ui container {{if .IsBlame}}fluid padded{{end}}"> <div class="ui container {{if .IsBlame}}fluid padded{{end}}">
{{template "base/alert" .}} {{template "base/alert" .}}
{{template "repo/code/recently_pushed_new_branches" .}}
{{if and (not .HideRepoInfo) (not .IsBlame)}} {{if and (not .HideRepoInfo) (not .IsBlame)}}
<div class="ui repo-description"> <div class="ui repo-description">
<div id="repo-desc"> <div id="repo-desc">
@ -84,7 +83,7 @@
<a href="{{.Repository.Link}}/find/{{.BranchNameSubURL}}" class="ui compact basic button">{{.locale.Tr "repo.find_file.go_to_file"}}</a> <a href="{{.Repository.Link}}/find/{{.BranchNameSubURL}}" class="ui compact basic button">{{.locale.Tr "repo.find_file.go_to_file"}}</a>
{{end}} {{end}}
{{if and .CanWriteCode .IsViewBranch (not .Repository.IsMirror) (not .Repository.IsArchived) (not .IsViewFile)}} {{if and .CanWriteCode .IsViewBranch (not .Repository.IsArchived) (not .IsViewFile)}}
<button class="ui dropdown basic compact jump button gt-mr-2"{{if not .Repository.CanEnableEditor}} disabled{{end}}> <button class="ui dropdown basic compact jump button gt-mr-2"{{if not .Repository.CanEnableEditor}} disabled{{end}}>
{{.locale.Tr "repo.editor.add_file"}} {{.locale.Tr "repo.editor.add_file"}}
{{svg "octicon-triangle-down" 14 "dropdown icon"}} {{svg "octicon-triangle-down" 14 "dropdown icon"}}

View File

@ -99,13 +99,15 @@
{{if and .IsSigned (ne .SignedUserID .ContextUser.ID)}} {{if and .IsSigned (ne .SignedUserID .ContextUser.ID)}}
<li class="follow"> <li class="follow">
{{if $.IsFollowing}} {{if $.IsFollowing}}
<button class="ui basic red button link-action" data-url="{{.ContextUser.HomeLink}}?action=unfollow"> <form method="post" action="{{.Link}}?action=unfollow&redirect_to={{$.Link}}">
{{svg "octicon-person"}} {{.locale.Tr "user.unfollow"}} {{$.CsrfTokenHtml}}
</button> <button type="submit" class="ui basic red button">{{svg "octicon-person"}} {{.locale.Tr "user.unfollow"}}</button>
</form>
{{else}} {{else}}
<button class="ui basic green button link-action" data-url="{{.ContextUser.HomeLink}}?action=follow"> <form method="post" action="{{.Link}}?action=follow&redirect_to={{$.Link}}">
{{svg "octicon-person"}} {{.locale.Tr "user.follow"}} {{$.CsrfTokenHtml}}
</button> <button type="submit" class="ui basic green button">{{svg "octicon-person"}} {{.locale.Tr "user.follow"}}</button>
</form>
{{end}} {{end}}
</li> </li>
{{end}} {{end}}

View File

@ -33,7 +33,7 @@
</a> </a>
<div class="divider"></div> <div class="divider"></div>
<a class="{{if not $.RepoIDs}}active{{end}} repo name item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&q={{$.Keyword}}"> <a class="{{if not $.RepoIDs}}active{{end}} repo name item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&q={{$.Keyword}}">
<span class="text truncate">{{.locale.Tr "all"}}</span> <span class="text truncate">All</span>
<span>{{CountFmt .TotalIssueCount}}</span> <span>{{CountFmt .TotalIssueCount}}</span>
</a> </a>
{{range .Repos}} {{range .Repos}}

View File

@ -8,7 +8,7 @@
</div> </div>
</div> </div>
{{else}} {{else}}
<div role="main" aria-label="{{.Title}}" class="page-content user profile packages"> <div role="main" aria-label="{{.Title}}" class="page-content user profile packages">
<div class="ui container"> <div class="ui container">
<div class="ui stackable grid"> <div class="ui stackable grid">
<div class="ui four wide column"> <div class="ui four wide column">
@ -22,6 +22,6 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{{end}} {{end}}
{{template "base/footer" .}} {{template "base/footer" .}}

View File

@ -16,7 +16,7 @@
<button class="ui green button">{{$.locale.Tr "packages.owner.settings.chef.keypair"}}</button> <button class="ui green button">{{$.locale.Tr "packages.owner.settings.chef.keypair"}}</button>
</form> </form>
<div class="field"> <div class="field">
<label>{{.locale.Tr "packages.registry.documentation" "Chef" "https://docs.gitea.io/en-us/usage/packages/chef/" | Safe}}</label> <label>{{.locale.Tr "packages.chef.documentation" "https://docs.gitea.io/en-us/usage/packages/chef/" | Safe}}</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -138,7 +138,7 @@ func TestPullRequestTargetEvent(t *testing.T) {
// load and compare ActionRun // load and compare ActionRun
actionRun := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRun{RepoID: baseRepo.ID}) actionRun := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRun{RepoID: baseRepo.ID})
assert.Equal(t, addFileToForkedResp.Commit.SHA, actionRun.CommitSHA) assert.Equal(t, addWorkflowToBaseResp.Commit.SHA, actionRun.CommitSHA)
assert.Equal(t, actions_module.GithubEventPullRequestTarget, actionRun.TriggerEvent) assert.Equal(t, actions_module.GithubEventPullRequestTarget, actionRun.TriggerEvent)
}) })
} }

View File

@ -120,9 +120,9 @@ func testCreateBranches(t *testing.T, giteaURL *url.URL) {
req := NewRequest(t, "GET", redirectURL) req := NewRequest(t, "GET", redirectURL)
resp := session.MakeRequest(t, req, http.StatusOK) resp := session.MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body) htmlDoc := NewHTMLParser(t, resp.Body)
assert.Contains(t, assert.Equal(t,
strings.TrimSpace(htmlDoc.doc.Find(".ui.message").Text()),
test.FlashMessage, test.FlashMessage,
strings.TrimSpace(htmlDoc.doc.Find(".ui.message").Text()),
) )
} }
} }

View File

@ -11,7 +11,6 @@ import webpack from 'webpack';
import {fileURLToPath} from 'node:url'; import {fileURLToPath} from 'node:url';
import {readFileSync} from 'node:fs'; import {readFileSync} from 'node:fs';
import {env} from 'node:process'; import {env} from 'node:process';
import {LightningCssMinifyPlugin} from 'lightningcss-loader';
const {EsbuildPlugin} = EsBuildLoader; const {EsbuildPlugin} = EsBuildLoader;
const {SourceMapDevToolPlugin, DefinePlugin} = webpack; const {SourceMapDevToolPlugin, DefinePlugin} = webpack;
@ -97,10 +96,9 @@ export default {
new EsbuildPlugin({ new EsbuildPlugin({
target: 'es2015', target: 'es2015',
minify: true, minify: true,
css: false, css: true,
legalComments: 'none', legalComments: 'none',
}), }),
new LightningCssMinifyPlugin(),
], ],
splitChunks: { splitChunks: {
chunks: 'async', chunks: 'async',