summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-10-05 19:09:27 +0800
committerLauris BH <lauris@nix.lv>2019-10-05 14:09:27 +0300
commitbd41a04a5613a2e017b458351bea0f02b767b893 (patch)
treed13e42c1f9664e09ae432250caaeca78df70ee72 /modules
parentfb7c23f911bebcb72f170f3d8bc8343546805f3b (diff)
downloadgitea-bd41a04a5613a2e017b458351bea0f02b767b893.tar.gz
gitea-bd41a04a5613a2e017b458351bea0f02b767b893.zip
Add extra user information when migrating release (#8331)
* add extra user information when migrating release * add migrations * fix tests
Diffstat (limited to 'modules')
-rw-r--r--modules/migrations/base/release.go3
-rw-r--r--modules/migrations/gitea.go26
-rw-r--r--modules/migrations/github.go8
-rw-r--r--modules/migrations/github_test.go2
4 files changed, 27 insertions, 12 deletions
diff --git a/modules/migrations/base/release.go b/modules/migrations/base/release.go
index 4ebc37315d..b2541f1bf5 100644
--- a/modules/migrations/base/release.go
+++ b/modules/migrations/base/release.go
@@ -25,6 +25,9 @@ type Release struct {
Body string
Draft bool
Prerelease bool
+ PublisherID int64
+ PublisherName string
+ PublisherEmail string
Assets []ReleaseAsset
Created time.Time
Published time.Time
diff --git a/modules/migrations/gitea.go b/modules/migrations/gitea.go
index 271c5616a7..1edac47a6e 100644
--- a/modules/migrations/gitea.go
+++ b/modules/migrations/gitea.go
@@ -175,18 +175,20 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error {
var rels = make([]*models.Release, 0, len(releases))
for _, release := range releases {
var rel = models.Release{
- RepoID: g.repo.ID,
- PublisherID: g.doer.ID,
- TagName: release.TagName,
- LowerTagName: strings.ToLower(release.TagName),
- Target: release.TargetCommitish,
- Title: release.Name,
- Sha1: release.TargetCommitish,
- Note: release.Body,
- IsDraft: release.Draft,
- IsPrerelease: release.Prerelease,
- IsTag: false,
- CreatedUnix: timeutil.TimeStamp(release.Created.Unix()),
+ RepoID: g.repo.ID,
+ PublisherID: g.doer.ID,
+ TagName: release.TagName,
+ LowerTagName: strings.ToLower(release.TagName),
+ Target: release.TargetCommitish,
+ Title: release.Name,
+ Sha1: release.TargetCommitish,
+ Note: release.Body,
+ IsDraft: release.Draft,
+ IsPrerelease: release.Prerelease,
+ IsTag: false,
+ CreatedUnix: timeutil.TimeStamp(release.Created.Unix()),
+ OriginalAuthor: release.PublisherName,
+ OriginalAuthorID: release.PublisherID,
}
// calc NumCommits
diff --git a/modules/migrations/github.go b/modules/migrations/github.go
index c5f29cabb7..754f98941c 100644
--- a/modules/migrations/github.go
+++ b/modules/migrations/github.go
@@ -214,6 +214,11 @@ func (g *GithubDownloaderV3) convertGithubRelease(rel *github.RepositoryRelease)
name = *rel.Name
}
+ var email string
+ if rel.Author.Email != nil {
+ email = *rel.Author.Email
+ }
+
r := &base.Release{
TagName: *rel.TagName,
TargetCommitish: *rel.TargetCommitish,
@@ -222,6 +227,9 @@ func (g *GithubDownloaderV3) convertGithubRelease(rel *github.RepositoryRelease)
Draft: *rel.Draft,
Prerelease: *rel.Prerelease,
Created: rel.CreatedAt.Time,
+ PublisherID: *rel.Author.ID,
+ PublisherName: *rel.Author.Login,
+ PublisherEmail: email,
Published: rel.PublishedAt.Time,
}
diff --git a/modules/migrations/github_test.go b/modules/migrations/github_test.go
index 62fce6bbcc..2a0a4edf32 100644
--- a/modules/migrations/github_test.go
+++ b/modules/migrations/github_test.go
@@ -167,6 +167,8 @@ func TestGitHubDownloadRepo(t *testing.T) {
Body: "Forked source from Gogs into Gitea\n",
Created: time.Date(2016, 10, 17, 02, 17, 59, 0, time.UTC),
Published: time.Date(2016, 11, 17, 15, 37, 0, 0, time.UTC),
+ PublisherID: 4726179,
+ PublisherName: "bkcsoft",
},
}, releases[len(releases)-1:])