1
0
Fork 0
forked from forgejo/forgejo

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
This commit is contained in:
mrsdizzie 2019-07-07 22:14:12 -04:00 committed by Lunny Xiao
parent fcda2d5b35
commit 1f1ecda541
28 changed files with 263 additions and 118 deletions

View file

@ -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
}