mirror of
https://github.com/go-gitea/gitea
synced 2024-10-19 20:10:10 +02:00
improve the logic of copy license info
This commit is contained in:
parent
44cf8e4eee
commit
648d0a0953
@ -101,14 +101,20 @@ func CopyLicense(originalRepo, destRepo *Repository) error {
|
||||
return err
|
||||
}
|
||||
if len(repoLicenses) > 0 {
|
||||
newRepoLicenses := make(RepoLicenseList, 0, len(repoLicenses))
|
||||
|
||||
time := timeutil.TimeStampNow()
|
||||
for i := range repoLicenses {
|
||||
repoLicenses[i].ID = 0
|
||||
repoLicenses[i].RepoID = destRepo.ID
|
||||
repoLicenses[i].CreatedUnix = time
|
||||
repoLicenses[i].UpdatedUnix = time
|
||||
for _, rl := range repoLicenses {
|
||||
newRepoLicense := &RepoLicense{
|
||||
RepoID: destRepo.ID,
|
||||
CommitID: rl.CommitID,
|
||||
License: rl.License,
|
||||
CreatedUnix: time,
|
||||
UpdatedUnix: time,
|
||||
}
|
||||
newRepoLicenses = append(newRepoLicenses, newRepoLicense)
|
||||
}
|
||||
if err := db.Insert(ctx, &repoLicenses); err != nil {
|
||||
if err := db.Insert(ctx, &newRepoLicenses); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user