summaryrefslogtreecommitdiffstats
path: root/modules/migrations/gitea.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 /modules/migrations/gitea.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 'modules/migrations/gitea.go')
-rw-r--r--modules/migrations/gitea.go63
1 files changed, 35 insertions, 28 deletions
diff --git a/modules/migrations/gitea.go b/modules/migrations/gitea.go
index 1df824c94f..b15aed5f4b 100644
--- a/modules/migrations/gitea.go
+++ b/modules/migrations/gitea.go
@@ -82,6 +82,7 @@ func (g *GiteaLocalUploader) CreateRepo(repo *base.Repository, opts base.Migrate
r, err := models.MigrateRepository(g.doer, owner, models.MigrateRepoOptions{
Name: g.repoName,
Description: repo.Description,
+ OriginalURL: repo.OriginalURL,
IsMirror: repo.IsMirror,
RemoteAddr: repo.CloneURL,
IsPrivate: repo.IsPrivate,
@@ -247,17 +248,19 @@ func (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error {
}
var is = models.Issue{
- RepoID: g.repo.ID,
- Repo: g.repo,
- Index: issue.Number,
- PosterID: g.doer.ID,
- Title: issue.Title,
- Content: issue.Content,
- IsClosed: issue.State == "closed",
- IsLocked: issue.IsLocked,
- MilestoneID: milestoneID,
- Labels: labels,
- CreatedUnix: util.TimeStamp(issue.Created.Unix()),
+ RepoID: g.repo.ID,
+ Repo: g.repo,
+ Index: issue.Number,
+ PosterID: g.doer.ID,
+ OriginalAuthor: issue.PosterName,
+ OriginalAuthorID: issue.PosterID,
+ Title: issue.Title,
+ Content: issue.Content,
+ IsClosed: issue.State == "closed",
+ IsLocked: issue.IsLocked,
+ MilestoneID: milestoneID,
+ Labels: labels,
+ CreatedUnix: util.TimeStamp(issue.Created.Unix()),
}
if issue.Closed != nil {
is.ClosedUnix = util.TimeStamp(issue.Closed.Unix())
@@ -293,11 +296,13 @@ func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error {
}
cms = append(cms, &models.Comment{
- IssueID: issueID,
- Type: models.CommentTypeComment,
- PosterID: g.doer.ID,
- Content: comment.Content,
- CreatedUnix: util.TimeStamp(comment.Created.Unix()),
+ IssueID: issueID,
+ Type: models.CommentTypeComment,
+ PosterID: g.doer.ID,
+ OriginalAuthor: comment.PosterName,
+ OriginalAuthorID: comment.PosterID,
+ Content: comment.Content,
+ CreatedUnix: util.TimeStamp(comment.Created.Unix()),
})
// TODO: Reactions
@@ -430,18 +435,20 @@ func (g *GiteaLocalUploader) newPullRequest(pr *base.PullRequest) (*models.PullR
HasMerged: pr.Merged,
Issue: &models.Issue{
- RepoID: g.repo.ID,
- Repo: g.repo,
- Title: pr.Title,
- Index: pr.Number,
- PosterID: g.doer.ID,
- Content: pr.Content,
- MilestoneID: milestoneID,
- IsPull: true,
- IsClosed: pr.State == "closed",
- IsLocked: pr.IsLocked,
- Labels: labels,
- CreatedUnix: util.TimeStamp(pr.Created.Unix()),
+ RepoID: g.repo.ID,
+ Repo: g.repo,
+ Title: pr.Title,
+ Index: pr.Number,
+ PosterID: g.doer.ID,
+ OriginalAuthor: pr.PosterName,
+ OriginalAuthorID: pr.PosterID,
+ Content: pr.Content,
+ MilestoneID: milestoneID,
+ IsPull: true,
+ IsClosed: pr.State == "closed",
+ IsLocked: pr.IsLocked,
+ Labels: labels,
+ CreatedUnix: util.TimeStamp(pr.Created.Unix()),
},
}