Skip to content

Commit 0fd90b4

Browse files
authored
Merge branch 'main' into bugfix/actions_rerun
2 parents fa6c3c1 + d5fa2e7 commit 0fd90b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+224
-87
lines changed

docs/content/doc/help/faq.en-us.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,14 @@ It is highly recommended to back-up your database before running these commands.
449449
If you are using Cloudflare, turn off the auto-minify option in the dashboard.
450450

451451
`Speed` -> `Optimization` -> Uncheck `HTML` within the `Auto-Minify` settings.
452+
453+
## How to adopt repositories from disk
454+
455+
- Add your (bare) repositories to the correct spot for your configuration (`repository.ROOT`), ensuring they are in the correct layout `<REPO_ROOT>/[user]/[repo].git`.
456+
- **Note:** the directory names must be lowercase.
457+
- You can also check `<ROOT_URL>/admin/config` for the repository root path.
458+
- Ensure that the user/org exists that you want to adopt repositories for.
459+
- As an admin, go to `<ROOT_URL>/admin/repos/unadopted` and search.
460+
- Users can also be given similar permissions via config [`ALLOW_ADOPTION_OF_UNADOPTED_REPOSITORIES`]({{< relref "doc/advanced/config-cheat-sheet.en-us.md#repository" >}}).
461+
- If the above steps are done correctly, you should be able to select repositories to adopt.
462+
- If no repositories are found, enable [debug logging]({{< relref "doc/advanced/config-cheat-sheet.en-us.md#repository" >}}) to check for any specific errors.

docs/content/doc/installation/with-docker-rootless.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Gitea provides automatically updated Docker images within its Docker Hub organiz
1919
possible to always use the latest stable tag or to use another service that handles updating
2020
Docker images.
2121

22-
The rootless image use Gitea internal SSH to provide Git protocol and doesn't support OpenSSH.
22+
The rootless image uses Gitea internal SSH to provide Git protocol and doesn't support OpenSSH.
2323

2424
This reference setup guides users through the setup based on `docker-compose`, but the installation
2525
of `docker-compose` is out of scope of this documentation. To install `docker-compose` itself, follow

models/activities/action.go

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,49 @@ func (a *Action) GetRepoAbsoluteLink() string {
223223
return setting.AppURL + url.PathEscape(a.GetRepoUserName()) + "/" + url.PathEscape(a.GetRepoName())
224224
}
225225

226+
// GetCommentHTMLURL returns link to action comment.
227+
func (a *Action) GetCommentHTMLURL() string {
228+
return a.getCommentHTMLURL(db.DefaultContext)
229+
}
230+
231+
func (a *Action) loadComment(ctx context.Context) (err error) {
232+
if a.CommentID == 0 || a.Comment != nil {
233+
return nil
234+
}
235+
a.Comment, err = issues_model.GetCommentByID(ctx, a.CommentID)
236+
return err
237+
}
238+
239+
func (a *Action) getCommentHTMLURL(ctx context.Context) string {
240+
if a == nil {
241+
return "#"
242+
}
243+
_ = a.loadComment(ctx)
244+
if a.Comment != nil {
245+
return a.Comment.HTMLURL()
246+
}
247+
if len(a.GetIssueInfos()) == 0 {
248+
return "#"
249+
}
250+
// Return link to issue
251+
issueIDString := a.GetIssueInfos()[0]
252+
issueID, err := strconv.ParseInt(issueIDString, 10, 64)
253+
if err != nil {
254+
return "#"
255+
}
256+
257+
issue, err := issues_model.GetIssueByID(ctx, issueID)
258+
if err != nil {
259+
return "#"
260+
}
261+
262+
if err = issue.LoadRepo(ctx); err != nil {
263+
return "#"
264+
}
265+
266+
return issue.HTMLURL()
267+
}
268+
226269
// GetCommentLink returns link to action comment.
227270
func (a *Action) GetCommentLink() string {
228271
return a.getCommentLink(db.DefaultContext)
@@ -232,11 +275,9 @@ func (a *Action) getCommentLink(ctx context.Context) string {
232275
if a == nil {
233276
return "#"
234277
}
235-
if a.Comment == nil && a.CommentID != 0 {
236-
a.Comment, _ = issues_model.GetCommentByID(ctx, a.CommentID)
237-
}
278+
_ = a.loadComment(ctx)
238279
if a.Comment != nil {
239-
return a.Comment.HTMLURL()
280+
return a.Comment.Link()
240281
}
241282
if len(a.GetIssueInfos()) == 0 {
242283
return "#"
@@ -257,7 +298,7 @@ func (a *Action) getCommentLink(ctx context.Context) string {
257298
return "#"
258299
}
259300

260-
return issue.HTMLURL()
301+
return issue.Link()
261302
}
262303

263304
// GetBranch returns the action's repository branch.

models/activities/action_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestAction_GetRepoLink(t *testing.T) {
3636
expected := path.Join(setting.AppSubURL, owner.Name, repo.Name)
3737
assert.Equal(t, expected, action.GetRepoLink())
3838
assert.Equal(t, repo.HTMLURL(), action.GetRepoAbsoluteLink())
39-
assert.Equal(t, comment.HTMLURL(), action.GetCommentLink())
39+
assert.Equal(t, comment.HTMLURL(), action.GetCommentHTMLURL())
4040
}
4141

4242
func TestGetFeeds(t *testing.T) {

models/activities/notification.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,22 @@ func (n *Notification) HTMLURL() string {
459459
return ""
460460
}
461461

462+
// Link formats a relative URL-string to the notification
463+
func (n *Notification) Link() string {
464+
switch n.Source {
465+
case NotificationSourceIssue, NotificationSourcePullRequest:
466+
if n.Comment != nil {
467+
return n.Comment.Link()
468+
}
469+
return n.Issue.Link()
470+
case NotificationSourceCommit:
471+
return n.Repository.Link() + "/commit/" + url.PathEscape(n.CommitID)
472+
case NotificationSourceRepository:
473+
return n.Repository.Link()
474+
}
475+
return ""
476+
}
477+
462478
// APIURL formats a URL-string to the notification
463479
func (n *Notification) APIURL() string {
464480
return setting.AppURL + "api/v1/notifications/threads/" + strconv.FormatInt(n.ID, 10)

models/issues/comment.go

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,21 +391,40 @@ func (c *Comment) HTMLURL() string {
391391
log.Error("loadRepo(%d): %v", c.Issue.RepoID, err)
392392
return ""
393393
}
394+
return c.Issue.HTMLURL() + c.hashLink()
395+
}
396+
397+
// Link formats a relative URL-string to the issue-comment
398+
func (c *Comment) Link() string {
399+
err := c.LoadIssue(db.DefaultContext)
400+
if err != nil { // Silently dropping errors :unamused:
401+
log.Error("LoadIssue(%d): %v", c.IssueID, err)
402+
return ""
403+
}
404+
err = c.Issue.LoadRepo(db.DefaultContext)
405+
if err != nil { // Silently dropping errors :unamused:
406+
log.Error("loadRepo(%d): %v", c.Issue.RepoID, err)
407+
return ""
408+
}
409+
return c.Issue.Link() + c.hashLink()
410+
}
411+
412+
func (c *Comment) hashLink() string {
394413
if c.Type == CommentTypeCode {
395414
if c.ReviewID == 0 {
396-
return fmt.Sprintf("%s/files#%s", c.Issue.HTMLURL(), c.HashTag())
415+
return "/files#" + c.HashTag()
397416
}
398417
if c.Review == nil {
399418
if err := c.LoadReview(); err != nil {
400419
log.Warn("LoadReview(%d): %v", c.ReviewID, err)
401-
return fmt.Sprintf("%s/files#%s", c.Issue.HTMLURL(), c.HashTag())
420+
return "/files#" + c.HashTag()
402421
}
403422
}
404423
if c.Review.Type <= ReviewTypePending {
405-
return fmt.Sprintf("%s/files#%s", c.Issue.HTMLURL(), c.HashTag())
424+
return "/files#" + c.HashTag()
406425
}
407426
}
408-
return fmt.Sprintf("%s#%s", c.Issue.HTMLURL(), c.HashTag())
427+
return "#" + c.HashTag()
409428
}
410429

411430
// APIURL formats a API-string to the issue-comment
@@ -708,8 +727,8 @@ func (c *Comment) UnsignedLine() uint64 {
708727
return uint64(c.Line)
709728
}
710729

711-
// CodeCommentURL returns the url to a comment in code
712-
func (c *Comment) CodeCommentURL() string {
730+
// CodeCommentLink returns the url to a comment in code
731+
func (c *Comment) CodeCommentLink() string {
713732
err := c.LoadIssue(db.DefaultContext)
714733
if err != nil { // Silently dropping errors :unamused:
715734
log.Error("LoadIssue(%d): %v", c.IssueID, err)
@@ -720,7 +739,7 @@ func (c *Comment) CodeCommentURL() string {
720739
log.Error("loadRepo(%d): %v", c.Issue.RepoID, err)
721740
return ""
722741
}
723-
return fmt.Sprintf("%s/files#%s", c.Issue.HTMLURL(), c.HashTag())
742+
return fmt.Sprintf("%s/files#%s", c.Issue.Link(), c.HashTag())
724743
}
725744

726745
// LoadPushCommits Load push commits

models/issues/issue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ func (issue *Issue) HTMLURL() string {
419419
return fmt.Sprintf("%s/%s/%d", issue.Repo.HTMLURL(), path, issue.Index)
420420
}
421421

422-
// Link returns the Link URL to this issue.
422+
// Link returns the issue's relative URL.
423423
func (issue *Issue) Link() string {
424424
var path string
425425
if issue.IsPull {

models/issues/pull.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -759,20 +759,20 @@ func GetPullRequestsByHeadBranch(ctx context.Context, headBranch string, headRep
759759
return prs, nil
760760
}
761761

762-
// GetBaseBranchHTMLURL returns the HTML URL of the base branch
763-
func (pr *PullRequest) GetBaseBranchHTMLURL() string {
762+
// GetBaseBranchLink returns the relative URL of the base branch
763+
func (pr *PullRequest) GetBaseBranchLink() string {
764764
if err := pr.LoadBaseRepo(db.DefaultContext); err != nil {
765765
log.Error("LoadBaseRepo: %v", err)
766766
return ""
767767
}
768768
if pr.BaseRepo == nil {
769769
return ""
770770
}
771-
return pr.BaseRepo.HTMLURL() + "/src/branch/" + util.PathEscapeSegments(pr.BaseBranch)
771+
return pr.BaseRepo.Link() + "/src/branch/" + util.PathEscapeSegments(pr.BaseBranch)
772772
}
773773

774-
// GetHeadBranchHTMLURL returns the HTML URL of the head branch
775-
func (pr *PullRequest) GetHeadBranchHTMLURL() string {
774+
// GetHeadBranchLink returns the relative URL of the head branch
775+
func (pr *PullRequest) GetHeadBranchLink() string {
776776
if pr.Flow == PullRequestFlowAGit {
777777
return ""
778778
}
@@ -784,7 +784,7 @@ func (pr *PullRequest) GetHeadBranchHTMLURL() string {
784784
if pr.HeadRepo == nil {
785785
return ""
786786
}
787-
return pr.HeadRepo.HTMLURL() + "/src/branch/" + util.PathEscapeSegments(pr.HeadBranch)
787+
return pr.HeadRepo.Link() + "/src/branch/" + util.PathEscapeSegments(pr.HeadBranch)
788788
}
789789

790790
// UpdateAllowEdits update if PR can be edited from maintainers

models/packages/descriptor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ type PackageFileDescriptor struct {
6565

6666
// PackageWebLink returns the package web link
6767
func (pd *PackageDescriptor) PackageWebLink() string {
68-
return fmt.Sprintf("%s/-/packages/%s/%s", pd.Owner.HTMLURL(), string(pd.Package.Type), url.PathEscape(pd.Package.LowerName))
68+
return fmt.Sprintf("%s/-/packages/%s/%s", pd.Owner.HomeLink(), string(pd.Package.Type), url.PathEscape(pd.Package.LowerName))
6969
}
7070

7171
// FullWebLink returns the package version web link

models/project/project.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ func (p *Project) LoadRepo(ctx context.Context) (err error) {
116116
return err
117117
}
118118

119+
// Link returns the project's relative URL.
119120
func (p *Project) Link() string {
120121
if p.OwnerID > 0 {
121122
err := p.LoadOwner(db.DefaultContext)

0 commit comments

Comments
 (0)