From 242f7f1a528af0b85ad0dd6fa88ed2d889b92385 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Mon, 25 Apr 2022 20:26:17 +0200 Subject: [PATCH] Add notags to fetch (#19487) (#19490) * Add notags to fetch (#19487) * gofumpt --- services/migrations/gitea_uploader.go | 44 +++++++++++++-------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go index 035ca2e5a2..e78d0c382e 100644 --- a/services/migrations/gitea_uploader.go +++ b/services/migrations/gitea_uploader.go @@ -33,9 +33,7 @@ import ( gouuid "github.com/google/uuid" ) -var ( - _ base.Uploader = &GiteaLocalUploader{} -) +var _ base.Uploader = &GiteaLocalUploader{} // GiteaLocalUploader implements an Uploader to gitea sites type GiteaLocalUploader struct { @@ -159,7 +157,7 @@ func (g *GiteaLocalUploader) CreateTopics(topics ...string) error { // CreateMilestones creates milestones func (g *GiteaLocalUploader) CreateMilestones(milestones ...*base.Milestone) error { - var mss = make([]*models.Milestone, 0, len(milestones)) + mss := make([]*models.Milestone, 0, len(milestones)) for _, milestone := range milestones { var deadline timeutil.TimeStamp if milestone.Deadline != nil { @@ -182,7 +180,7 @@ func (g *GiteaLocalUploader) CreateMilestones(milestones ...*base.Milestone) err milestone.Updated = &milestone.Created } - var ms = models.Milestone{ + ms := models.Milestone{ RepoID: g.repo.ID, Name: milestone.Title, Content: milestone.Description, @@ -210,7 +208,7 @@ func (g *GiteaLocalUploader) CreateMilestones(milestones ...*base.Milestone) err // CreateLabels creates labels func (g *GiteaLocalUploader) CreateLabels(labels ...*base.Label) error { - var lbs = make([]*models.Label, 0, len(labels)) + lbs := make([]*models.Label, 0, len(labels)) for _, label := range labels { lbs = append(lbs, &models.Label{ RepoID: g.repo.ID, @@ -232,7 +230,7 @@ func (g *GiteaLocalUploader) CreateLabels(labels ...*base.Label) error { // CreateReleases creates releases func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error { - var rels = make([]*models.Release, 0, len(releases)) + rels := make([]*models.Release, 0, len(releases)) for _, release := range releases { if release.Created.IsZero() { if !release.Published.IsZero() { @@ -242,7 +240,7 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error { } } - var rel = models.Release{ + rel := models.Release{ RepoID: g.repo.ID, TagName: release.TagName, LowerTagName: strings.ToLower(release.TagName), @@ -297,7 +295,7 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error { asset.Created = release.Created } } - var attach = repo_model.Attachment{ + attach := repo_model.Attachment{ UUID: gouuid.New().String(), Name: asset.Name, DownloadCount: int64(*asset.DownloadCount), @@ -348,7 +346,7 @@ func (g *GiteaLocalUploader) SyncTags() error { // CreateIssues creates issues func (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error { - var iss = make([]*models.Issue, 0, len(issues)) + iss := make([]*models.Issue, 0, len(issues)) for _, issue := range issues { var labels []*models.Label for _, label := range issue.Labels { @@ -381,7 +379,7 @@ func (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error { } } - var is = models.Issue{ + is := models.Issue{ RepoID: g.repo.ID, Repo: g.repo, Index: issue.Number, @@ -433,7 +431,7 @@ func (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error { g.userMap[reaction.UserID] = userid } } - var res = models.Reaction{ + res := models.Reaction{ Type: reaction.Content, CreatedUnix: timeutil.TimeStampNow(), } @@ -464,7 +462,7 @@ func (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error { // CreateComments creates comments of issues func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error { - var cms = make([]*models.Comment, 0, len(comments)) + cms := make([]*models.Comment, 0, len(comments)) for _, comment := range comments { var issue *models.Issue issueInter, ok := g.issues.Load(comment.IssueIndex) @@ -528,7 +526,7 @@ func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error { g.userMap[reaction.UserID] = userid } } - var res = models.Reaction{ + res := models.Reaction{ Type: reaction.Content, CreatedUnix: timeutil.TimeStampNow(), } @@ -553,7 +551,7 @@ func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error { // CreatePullRequests creates pull requests func (g *GiteaLocalUploader) CreatePullRequests(prs ...*base.PullRequest) error { - var gprs = make([]*models.PullRequest, 0, len(prs)) + gprs := make([]*models.PullRequest, 0, len(prs)) for _, pr := range prs { gpr, err := g.newPullRequest(pr) if err != nil { @@ -652,7 +650,7 @@ func (g *GiteaLocalUploader) newPullRequest(pr *base.PullRequest) (*models.PullR return nil, err } - var head = "unknown repository" + head := "unknown repository" if pr.IsForkPullRequest() && pr.State != "closed" { if pr.Head.OwnerName != "" { remote := pr.Head.OwnerName @@ -669,7 +667,7 @@ func (g *GiteaLocalUploader) newPullRequest(pr *base.PullRequest) (*models.PullR } if ok { - _, err = git.NewCommand("fetch", remote, pr.Head.Ref).RunInDir(g.repo.RepoPath()) + _, err = git.NewCommandContext(g.ctx, "fetch", "--no-tags", "--", remote, pr.Head.Ref).RunInDir(g.repo.RepoPath()) if err != nil { log.Error("Fetch branch from %s failed: %v", pr.Head.CloneURL, err) } else { @@ -723,7 +721,7 @@ func (g *GiteaLocalUploader) newPullRequest(pr *base.PullRequest) (*models.PullR pr.Updated = pr.Created } - var issue = models.Issue{ + issue := models.Issue{ RepoID: g.repo.ID, Repo: g.repo, Title: pr.Title, @@ -773,7 +771,7 @@ func (g *GiteaLocalUploader) newPullRequest(pr *base.PullRequest) (*models.PullR g.userMap[reaction.UserID] = userid } } - var res = models.Reaction{ + res := models.Reaction{ Type: reaction.Content, CreatedUnix: timeutil.TimeStampNow(), } @@ -787,7 +785,7 @@ func (g *GiteaLocalUploader) newPullRequest(pr *base.PullRequest) (*models.PullR issue.Reactions = append(issue.Reactions, &res) } - var pullRequest = models.PullRequest{ + pullRequest := models.PullRequest{ HeadRepoID: g.repo.ID, HeadBranch: head, BaseRepoID: g.repo.ID, @@ -830,7 +828,7 @@ func convertReviewState(state string) models.ReviewType { // CreateReviews create pull request reviews func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error { - var cms = make([]*models.Review, 0, len(reviews)) + cms := make([]*models.Review, 0, len(reviews)) for _, review := range reviews { var issue *models.Issue issueInter, ok := g.issues.Load(review.IssueIndex) @@ -862,7 +860,7 @@ func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error { review.CreatedAt = time.Unix(int64(issue.CreatedUnix), 0) } - var cm = models.Review{ + cm := models.Review{ Type: convertReviewState(review.State), IssueID: issue.ID, Content: review.Content, @@ -926,7 +924,7 @@ func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error { comment.UpdatedAt = comment.CreatedAt } - var c = models.Comment{ + c := models.Comment{ Type: models.CommentTypeCode, PosterID: comment.PosterID, IssueID: issue.ID,