forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'giteaoffical/main'
* giteaoffical/main: remove not needed (go-gitea#19128) Add warning to set SENDMAIL_ARGS to -- (go-gitea#19102) Do not send activation email if manual confirm is set (go-gitea#19119) Update tool dependencies (go-gitea#19120) Delete related notifications on issue deletion too (go-gitea#18953) nit fix (go-gitea#19116) Store the foreign ID of issues during migration (go-gitea#18446) Remove italics for `due_date_not_set` (go-gitea#19113)
- Loading branch information
Showing
45 changed files
with
476 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] # empty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2022 Gitea. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package foreignreference | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// ErrLocalIndexNotExist represents a "LocalIndexNotExist" kind of error. | ||
type ErrLocalIndexNotExist struct { | ||
RepoID int64 | ||
ForeignIndex int64 | ||
Type string | ||
} | ||
|
||
// ErrLocalIndexNotExist checks if an error is a ErrLocalIndexNotExist. | ||
func IsErrLocalIndexNotExist(err error) bool { | ||
_, ok := err.(ErrLocalIndexNotExist) | ||
return ok | ||
} | ||
|
||
func (err ErrLocalIndexNotExist) Error() string { | ||
return fmt.Sprintf("repository %d has no LocalIndex for ForeignIndex %d of type %s", err.RepoID, err.ForeignIndex, err.Type) | ||
} | ||
|
||
// ErrForeignIndexNotExist represents a "ForeignIndexNotExist" kind of error. | ||
type ErrForeignIndexNotExist struct { | ||
RepoID int64 | ||
LocalIndex int64 | ||
Type string | ||
} | ||
|
||
// ErrForeignIndexNotExist checks if an error is a ErrForeignIndexNotExist. | ||
func IsErrForeignIndexNotExist(err error) bool { | ||
_, ok := err.(ErrForeignIndexNotExist) | ||
return ok | ||
} | ||
|
||
func (err ErrForeignIndexNotExist) Error() string { | ||
return fmt.Sprintf("repository %d has no ForeignIndex for LocalIndex %d of type %s", err.RepoID, err.LocalIndex, err.Type) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2022 Gitea. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package foreignreference | ||
|
||
import ( | ||
"code.gitea.io/gitea/models/db" | ||
) | ||
|
||
// Type* are valid values for the Type field of ForeignReference | ||
const ( | ||
TypeIssue = "issue" | ||
TypePullRequest = "pull_request" | ||
TypeComment = "comment" | ||
TypeReview = "review" | ||
TypeReviewComment = "review_comment" | ||
TypeRelease = "release" | ||
) | ||
|
||
// ForeignReference represents external references | ||
type ForeignReference struct { | ||
// RepoID is the first column in all indices. now we only need 2 indices: (repo, local) and (repo, foreign, type) | ||
RepoID int64 `xorm:"UNIQUE(repo_foreign_type) INDEX(repo_local)" ` | ||
LocalIndex int64 `xorm:"INDEX(repo_local)"` // the resource key inside Gitea, it can be IssueIndex, or some model ID. | ||
ForeignIndex string `xorm:"INDEX UNIQUE(repo_foreign_type)"` | ||
Type string `xorm:"VARCHAR(16) INDEX UNIQUE(repo_foreign_type)"` | ||
} | ||
|
||
func init() { | ||
db.RegisterModel(new(ForeignReference)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2022 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package migrations | ||
|
||
import ( | ||
"fmt" | ||
|
||
"xorm.io/xorm" | ||
) | ||
|
||
func createForeignReferenceTable(x *xorm.Engine) error { | ||
type ForeignReference struct { | ||
// RepoID is the first column in all indices. now we only need 2 indices: (repo, local) and (repo, foreign, type) | ||
RepoID int64 `xorm:"UNIQUE(repo_foreign_type) INDEX(repo_local)" ` | ||
LocalIndex int64 `xorm:"INDEX(repo_local)"` // the resource key inside Gitea, it can be IssueIndex, or some model ID. | ||
ForeignIndex string `xorm:"INDEX UNIQUE(repo_foreign_type)"` | ||
Type string `xorm:"VARCHAR(16) INDEX UNIQUE(repo_foreign_type)"` | ||
} | ||
|
||
if err := x.Sync2(new(ForeignReference)); err != nil { | ||
return fmt.Errorf("Sync2: %v", err) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.