summaryrefslogtreecommitdiffstats
path: root/models/repo.go
diff options
context:
space:
mode:
authormrsdizzie <info@mrsdizzie.com>2019-07-07 22:14:12 -0400
committerLunny Xiao <xiaolunwen@gmail.com>2019-07-08 10:14:12 +0800
commit1f1ecda541d7f526c004e7bfabab814dbc84dc2c (patch)
treeb53d4e692de9b4a5cc0ebfebf09a4cb5d8d5880f /models/repo.go
parentfcda2d5b35ec9bec9a8e8fa0a0fb04cb21593648 (diff)
downloadgitea-1f1ecda541d7f526c004e7bfabab814dbc84dc2c.tar.gz
gitea-1f1ecda541d7f526c004e7bfabab814dbc84dc2c.zip
Display original author and URL information when showing migrated issues/comments (#7352)
* Store original author info for migrated issues and comments Keep original author name for displaying in Gitea interface and also store original author user ID for potential future use in linking accounts from old location. * Add original_url for repo Store the original URL for a migrated repo Clean up migrations/tests * fix migration * fix golangci-lint * make 'make revive' happy also * Modify templates to use OriginalAuthor if set Use the original author name in templates if it is set rather than the user who migrated/currently owns the issues * formatting fixes * make generate-swagger * Use default avatar for imported comments * Remove no longer used IgnoreIssueAuthor option * Add OriginalAuthorID to swagger also
Diffstat (limited to 'models/repo.go')
-rw-r--r--models/repo.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/models/repo.go b/models/repo.go
index 59ce18fa88..9bedeba952 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -136,6 +136,7 @@ type Repository struct {
Name string `xorm:"INDEX NOT NULL"`
Description string
Website string
+ OriginalURL string
DefaultBranch string
NumWatches int
@@ -847,6 +848,7 @@ func (repo *Repository) CloneLink() (cl *CloneLink) {
type MigrateRepoOptions struct {
Name string
Description string
+ OriginalURL string
IsPrivate bool
IsMirror bool
RemoteAddr string
@@ -878,6 +880,7 @@ func MigrateRepository(doer, u *User, opts MigrateRepoOptions) (*Repository, err
repo, err := CreateRepository(doer, u, CreateRepoOptions{
Name: opts.Name,
Description: opts.Description,
+ OriginalURL: opts.OriginalURL,
IsPrivate: opts.IsPrivate,
IsMirror: opts.IsMirror,
})
@@ -1092,6 +1095,7 @@ func initRepoCommit(tmpPath string, sig *git.Signature) (err error) {
type CreateRepoOptions struct {
Name string
Description string
+ OriginalURL string
Gitignores string
License string
Readme string
@@ -1358,6 +1362,7 @@ func CreateRepository(doer, u *User, opts CreateRepoOptions) (_ *Repository, err
Name: opts.Name,
LowerName: strings.ToLower(opts.Name),
Description: opts.Description,
+ OriginalURL: opts.OriginalURL,
IsPrivate: opts.IsPrivate,
IsFsckEnabled: !opts.IsMirror,
CloseIssuesViaCommitInAnyBranch: setting.Repository.DefaultCloseIssuesViaCommitsInAnyBranch,
@@ -2678,3 +2683,13 @@ func (repo *Repository) DeleteAvatar() error {
}
return sess.Commit()
}
+
+// GetOriginalURLHostname returns the hostname of a URL or the URL
+func (repo *Repository) GetOriginalURLHostname() string {
+ u, err := url.Parse(repo.OriginalURL)
+ if err != nil {
+ return repo.OriginalURL
+ }
+
+ return u.Host
+}