You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

506 lines
13 KiB

10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
Add Attachment API (#3478) * Add Attachment API * repos/:owner/:repo/releases (add attachments) * repos/:owner/:repo/releases/:id (add attachments) * repos/:owner/:repo/releases/:id/attachments * repos/:owner/:repo/releases/:id/attachments/:attachment_id Signed-off-by: Jonas Franz <info@jonasfranz.de> * Add unit tests for new attachment functions Fix comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * fix lint * Update vendor.json Signed-off-by: Jonas Franz <info@jonasfranz.software> * remove version of sdk Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests Add missing license header Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add CreateReleaseAttachment Add EditReleaseAttachment Add DeleteReleaseAttachment Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add filename query parameter for choosing another name for an attachment Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix order of imports Signed-off-by: Jonas Franz <info@jonasfranz.software> * Restricting updatable attachment columns Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update go-sdk Replace Attachments with Assets Signed-off-by: Jonas Franz <info@jonasfranz.de> * Update go-sdk Signed-off-by: Jonas Franz <info@jonasfranz.de> * Updating go-sdk and regenerating swagger Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing file of go-sdk Signed-off-by: Jonas Franz <info@jonasfranz.software> * Change origin of code.gitea.io/sdk to code.gitea.io/sdk Update code.gitea.io/sdk Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update swagger Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update updateAttachment
6 years ago
Add Attachment API (#3478) * Add Attachment API * repos/:owner/:repo/releases (add attachments) * repos/:owner/:repo/releases/:id (add attachments) * repos/:owner/:repo/releases/:id/attachments * repos/:owner/:repo/releases/:id/attachments/:attachment_id Signed-off-by: Jonas Franz <info@jonasfranz.de> * Add unit tests for new attachment functions Fix comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * fix lint * Update vendor.json Signed-off-by: Jonas Franz <info@jonasfranz.software> * remove version of sdk Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests Add missing license header Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add CreateReleaseAttachment Add EditReleaseAttachment Add DeleteReleaseAttachment Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add filename query parameter for choosing another name for an attachment Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix order of imports Signed-off-by: Jonas Franz <info@jonasfranz.software> * Restricting updatable attachment columns Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update go-sdk Replace Attachments with Assets Signed-off-by: Jonas Franz <info@jonasfranz.de> * Update go-sdk Signed-off-by: Jonas Franz <info@jonasfranz.de> * Updating go-sdk and regenerating swagger Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing file of go-sdk Signed-off-by: Jonas Franz <info@jonasfranz.software> * Change origin of code.gitea.io/sdk to code.gitea.io/sdk Update code.gitea.io/sdk Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update swagger Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update updateAttachment
6 years ago
Add Attachment API (#3478) * Add Attachment API * repos/:owner/:repo/releases (add attachments) * repos/:owner/:repo/releases/:id (add attachments) * repos/:owner/:repo/releases/:id/attachments * repos/:owner/:repo/releases/:id/attachments/:attachment_id Signed-off-by: Jonas Franz <info@jonasfranz.de> * Add unit tests for new attachment functions Fix comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * fix lint * Update vendor.json Signed-off-by: Jonas Franz <info@jonasfranz.software> * remove version of sdk Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests Add missing license header Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add CreateReleaseAttachment Add EditReleaseAttachment Add DeleteReleaseAttachment Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add filename query parameter for choosing another name for an attachment Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix order of imports Signed-off-by: Jonas Franz <info@jonasfranz.software> * Restricting updatable attachment columns Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update go-sdk Replace Attachments with Assets Signed-off-by: Jonas Franz <info@jonasfranz.de> * Update go-sdk Signed-off-by: Jonas Franz <info@jonasfranz.de> * Updating go-sdk and regenerating swagger Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing file of go-sdk Signed-off-by: Jonas Franz <info@jonasfranz.software> * Change origin of code.gitea.io/sdk to code.gitea.io/sdk Update code.gitea.io/sdk Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update swagger Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update updateAttachment
6 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
9 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package models
  5. import (
  6. "fmt"
  7. "sort"
  8. "strings"
  9. "code.gitea.io/git"
  10. "code.gitea.io/gitea/modules/log"
  11. "code.gitea.io/gitea/modules/process"
  12. "code.gitea.io/gitea/modules/setting"
  13. "code.gitea.io/gitea/modules/util"
  14. api "code.gitea.io/sdk/gitea"
  15. "github.com/go-xorm/builder"
  16. )
  17. // Release represents a release of repository.
  18. type Release struct {
  19. ID int64 `xorm:"pk autoincr"`
  20. RepoID int64 `xorm:"INDEX UNIQUE(n)"`
  21. Repo *Repository `xorm:"-"`
  22. PublisherID int64 `xorm:"INDEX"`
  23. Publisher *User `xorm:"-"`
  24. TagName string `xorm:"INDEX UNIQUE(n)"`
  25. LowerTagName string
  26. Target string
  27. Title string
  28. Sha1 string `xorm:"VARCHAR(40)"`
  29. NumCommits int64
  30. NumCommitsBehind int64 `xorm:"-"`
  31. Note string `xorm:"TEXT"`
  32. IsDraft bool `xorm:"NOT NULL DEFAULT false"`
  33. IsPrerelease bool `xorm:"NOT NULL DEFAULT false"`
  34. IsTag bool `xorm:"NOT NULL DEFAULT false"`
  35. Attachments []*Attachment `xorm:"-"`
  36. CreatedUnix util.TimeStamp `xorm:"INDEX"`
  37. }
  38. func (r *Release) loadAttributes(e Engine) error {
  39. var err error
  40. if r.Repo == nil {
  41. r.Repo, err = GetRepositoryByID(r.RepoID)
  42. if err != nil {
  43. return err
  44. }
  45. }
  46. if r.Publisher == nil {
  47. r.Publisher, err = GetUserByID(r.PublisherID)
  48. if err != nil {
  49. return err
  50. }
  51. }
  52. return GetReleaseAttachments(r)
  53. }
  54. // LoadAttributes load repo and publisher attributes for a release
  55. func (r *Release) LoadAttributes() error {
  56. return r.loadAttributes(x)
  57. }
  58. // APIURL the api url for a release. release must have attributes loaded
  59. func (r *Release) APIURL() string {
  60. return fmt.Sprintf("%sapi/v1/%s/releases/%d",
  61. setting.AppURL, r.Repo.FullName(), r.ID)
  62. }
  63. // ZipURL the zip url for a release. release must have attributes loaded
  64. func (r *Release) ZipURL() string {
  65. return fmt.Sprintf("%s/archive/%s.zip", r.Repo.HTMLURL(), r.TagName)
  66. }
  67. // TarURL the tar.gz url for a release. release must have attributes loaded
  68. func (r *Release) TarURL() string {
  69. return fmt.Sprintf("%s/archive/%s.tar.gz", r.Repo.HTMLURL(), r.TagName)
  70. }
  71. // APIFormat convert a Release to api.Release
  72. func (r *Release) APIFormat() *api.Release {
  73. assets := make([]*api.Attachment, 0)
  74. for _, att := range r.Attachments {
  75. assets = append(assets, att.APIFormat())
  76. }
  77. return &api.Release{
  78. ID: r.ID,
  79. TagName: r.TagName,
  80. Target: r.Target,
  81. Title: r.Title,
  82. Note: r.Note,
  83. URL: r.APIURL(),
  84. TarURL: r.TarURL(),
  85. ZipURL: r.ZipURL(),
  86. IsDraft: r.IsDraft,
  87. IsPrerelease: r.IsPrerelease,
  88. CreatedAt: r.CreatedUnix.AsTime(),
  89. PublishedAt: r.CreatedUnix.AsTime(),
  90. Publisher: r.Publisher.APIFormat(),
  91. Attachments: assets,
  92. }
  93. }
  94. // IsReleaseExist returns true if release with given tag name already exists.
  95. func IsReleaseExist(repoID int64, tagName string) (bool, error) {
  96. if len(tagName) == 0 {
  97. return false, nil
  98. }
  99. return x.Get(&Release{RepoID: repoID, LowerTagName: strings.ToLower(tagName)})
  100. }
  101. func createTag(gitRepo *git.Repository, rel *Release) error {
  102. // Only actual create when publish.
  103. if !rel.IsDraft {
  104. if !gitRepo.IsTagExist(rel.TagName) {
  105. commit, err := gitRepo.GetCommit(rel.Target)
  106. if err != nil {
  107. return fmt.Errorf("GetCommit: %v", err)
  108. }
  109. // Trim '--' prefix to prevent command line argument vulnerability.
  110. rel.TagName = strings.TrimPrefix(rel.TagName, "--")
  111. if err = gitRepo.CreateTag(rel.TagName, commit.ID.String()); err != nil {
  112. if strings.Contains(err.Error(), "is not a valid tag name") {
  113. return ErrInvalidTagName{rel.TagName}
  114. }
  115. return err
  116. }
  117. rel.LowerTagName = strings.ToLower(rel.TagName)
  118. }
  119. commit, err := gitRepo.GetTagCommit(rel.TagName)
  120. if err != nil {
  121. return fmt.Errorf("GetTagCommit: %v", err)
  122. }
  123. rel.Sha1 = commit.ID.String()
  124. rel.CreatedUnix = util.TimeStamp(commit.Author.When.Unix())
  125. rel.NumCommits, err = commit.CommitsCount()
  126. if err != nil {
  127. return fmt.Errorf("CommitsCount: %v", err)
  128. }
  129. } else {
  130. rel.CreatedUnix = util.TimeStampNow()
  131. }
  132. return nil
  133. }
  134. func addReleaseAttachments(releaseID int64, attachmentUUIDs []string) (err error) {
  135. // Check attachments
  136. var attachments = make([]*Attachment, 0)
  137. for _, uuid := range attachmentUUIDs {
  138. attach, err := getAttachmentByUUID(x, uuid)
  139. if err != nil {
  140. if IsErrAttachmentNotExist(err) {
  141. continue
  142. }
  143. return fmt.Errorf("getAttachmentByUUID [%s]: %v", uuid, err)
  144. }
  145. attachments = append(attachments, attach)
  146. }
  147. for i := range attachments {
  148. attachments[i].ReleaseID = releaseID
  149. // No assign value could be 0, so ignore AllCols().
  150. if _, err = x.ID(attachments[i].ID).Update(attachments[i]); err != nil {
  151. return fmt.Errorf("update attachment [%d]: %v", attachments[i].ID, err)
  152. }
  153. }
  154. return
  155. }
  156. // CreateRelease creates a new release of repository.
  157. func CreateRelease(gitRepo *git.Repository, rel *Release, attachmentUUIDs []string) error {
  158. isExist, err := IsReleaseExist(rel.RepoID, rel.TagName)
  159. if err != nil {
  160. return err
  161. } else if isExist {
  162. return ErrReleaseAlreadyExist{rel.TagName}
  163. }
  164. if err = createTag(gitRepo, rel); err != nil {
  165. return err
  166. }
  167. rel.LowerTagName = strings.ToLower(rel.TagName)
  168. _, err = x.InsertOne(rel)
  169. if err != nil {
  170. return err
  171. }
  172. err = addReleaseAttachments(rel.ID, attachmentUUIDs)
  173. if err != nil {
  174. return err
  175. }
  176. if !rel.IsDraft {
  177. if err := rel.LoadAttributes(); err != nil {
  178. log.Error(2, "LoadAttributes: %v", err)
  179. } else {
  180. mode, _ := AccessLevel(rel.Publisher, rel.Repo)
  181. if err := PrepareWebhooks(rel.Repo, HookEventRelease, &api.ReleasePayload{
  182. Action: api.HookReleasePublished,
  183. Release: rel.APIFormat(),
  184. Repository: rel.Repo.APIFormat(mode),
  185. Sender: rel.Publisher.APIFormat(),
  186. }); err != nil {
  187. log.Error(2, "PrepareWebhooks: %v", err)
  188. } else {
  189. go HookQueue.Add(rel.Repo.ID)
  190. }
  191. }
  192. }
  193. return nil
  194. }
  195. // GetRelease returns release by given ID.
  196. func GetRelease(repoID int64, tagName string) (*Release, error) {
  197. isExist, err := IsReleaseExist(repoID, tagName)
  198. if err != nil {
  199. return nil, err
  200. } else if !isExist {
  201. return nil, ErrReleaseNotExist{0, tagName}
  202. }
  203. rel := &Release{RepoID: repoID, LowerTagName: strings.ToLower(tagName)}
  204. _, err = x.Get(rel)
  205. return rel, err
  206. }
  207. // GetReleaseByID returns release with given ID.
  208. func GetReleaseByID(id int64) (*Release, error) {
  209. rel := new(Release)
  210. has, err := x.
  211. ID(id).
  212. Get(rel)
  213. if err != nil {
  214. return nil, err
  215. } else if !has {
  216. return nil, ErrReleaseNotExist{id, ""}
  217. }
  218. return rel, nil
  219. }
  220. // FindReleasesOptions describes the conditions to Find releases
  221. type FindReleasesOptions struct {
  222. IncludeDrafts bool
  223. IncludeTags bool
  224. TagNames []string
  225. }
  226. func (opts *FindReleasesOptions) toConds(repoID int64) builder.Cond {
  227. var cond = builder.NewCond()
  228. cond = cond.And(builder.Eq{"repo_id": repoID})
  229. if !opts.IncludeDrafts {
  230. cond = cond.And(builder.Eq{"is_draft": false})
  231. }
  232. if !opts.IncludeTags {
  233. cond = cond.And(builder.Eq{"is_tag": false})
  234. }
  235. if len(opts.TagNames) > 0 {
  236. cond = cond.And(builder.In("tag_name", opts.TagNames))
  237. }
  238. return cond
  239. }
  240. // GetReleasesByRepoID returns a list of releases of repository.
  241. func GetReleasesByRepoID(repoID int64, opts FindReleasesOptions, page, pageSize int) (rels []*Release, err error) {
  242. if page <= 0 {
  243. page = 1
  244. }
  245. err = x.
  246. Desc("created_unix", "id").
  247. Limit(pageSize, (page-1)*pageSize).
  248. Where(opts.toConds(repoID)).
  249. Find(&rels)
  250. return rels, err
  251. }
  252. // GetReleaseCountByRepoID returns the count of releases of repository
  253. func GetReleaseCountByRepoID(repoID int64, opts FindReleasesOptions) (int64, error) {
  254. return x.Where(opts.toConds(repoID)).Count(&Release{})
  255. }
  256. type releaseMetaSearch struct {
  257. ID []int64
  258. Rel []*Release
  259. }
  260. func (s releaseMetaSearch) Len() int {
  261. return len(s.ID)
  262. }
  263. func (s releaseMetaSearch) Swap(i, j int) {
  264. s.ID[i], s.ID[j] = s.ID[j], s.ID[i]
  265. s.Rel[i], s.Rel[j] = s.Rel[j], s.Rel[i]
  266. }
  267. func (s releaseMetaSearch) Less(i, j int) bool {
  268. return s.ID[i] < s.ID[j]
  269. }
  270. // GetReleaseAttachments retrieves the attachments for releases
  271. func GetReleaseAttachments(rels ...*Release) (err error) {
  272. if len(rels) == 0 {
  273. return
  274. }
  275. // To keep this efficient as possible sort all releases by id,
  276. // select attachments by release id,
  277. // then merge join them
  278. // Sort
  279. var sortedRels = releaseMetaSearch{ID: make([]int64, len(rels)), Rel: make([]*Release, len(rels))}
  280. var attachments []*Attachment
  281. for index, element := range rels {
  282. element.Attachments = []*Attachment{}
  283. sortedRels.ID[index] = element.ID
  284. sortedRels.Rel[index] = element
  285. }
  286. sort.Sort(sortedRels)
  287. // Select attachments
  288. err = x.
  289. Asc("release_id").
  290. In("release_id", sortedRels.ID).
  291. Find(&attachments, Attachment{})
  292. if err != nil {
  293. return err
  294. }
  295. // merge join
  296. var currentIndex = 0
  297. for _, attachment := range attachments {
  298. for sortedRels.ID[currentIndex] < attachment.ReleaseID {
  299. currentIndex++
  300. }
  301. sortedRels.Rel[currentIndex].Attachments = append(sortedRels.Rel[currentIndex].Attachments, attachment)
  302. }
  303. return
  304. }
  305. type releaseSorter struct {
  306. rels []*Release
  307. }
  308. func (rs *releaseSorter) Len() int {
  309. return len(rs.rels)
  310. }
  311. func (rs *releaseSorter) Less(i, j int) bool {
  312. diffNum := rs.rels[i].NumCommits - rs.rels[j].NumCommits
  313. if diffNum != 0 {
  314. return diffNum > 0
  315. }
  316. return rs.rels[i].CreatedUnix > rs.rels[j].CreatedUnix
  317. }
  318. func (rs *releaseSorter) Swap(i, j int) {
  319. rs.rels[i], rs.rels[j] = rs.rels[j], rs.rels[i]
  320. }
  321. // SortReleases sorts releases by number of commits and created time.
  322. func SortReleases(rels []*Release) {
  323. sorter := &releaseSorter{rels: rels}
  324. sort.Sort(sorter)
  325. }
  326. // UpdateRelease updates information of a release.
  327. func UpdateRelease(doer *User, gitRepo *git.Repository, rel *Release, attachmentUUIDs []string) (err error) {
  328. if err = createTag(gitRepo, rel); err != nil {
  329. return err
  330. }
  331. rel.LowerTagName = strings.ToLower(rel.TagName)
  332. _, err = x.ID(rel.ID).AllCols().Update(rel)
  333. if err != nil {
  334. return err
  335. }
  336. err = rel.loadAttributes(x)
  337. if err != nil {
  338. return err
  339. }
  340. err = addReleaseAttachments(rel.ID, attachmentUUIDs)
  341. mode, _ := AccessLevel(doer, rel.Repo)
  342. if err1 := PrepareWebhooks(rel.Repo, HookEventRelease, &api.ReleasePayload{
  343. Action: api.HookReleaseUpdated,
  344. Release: rel.APIFormat(),
  345. Repository: rel.Repo.APIFormat(mode),
  346. Sender: rel.Publisher.APIFormat(),
  347. }); err1 != nil {
  348. log.Error(2, "PrepareWebhooks: %v", err)
  349. } else {
  350. go HookQueue.Add(rel.Repo.ID)
  351. }
  352. return err
  353. }
  354. // DeleteReleaseByID deletes a release and corresponding Git tag by given ID.
  355. func DeleteReleaseByID(id int64, u *User, delTag bool) error {
  356. rel, err := GetReleaseByID(id)
  357. if err != nil {
  358. return fmt.Errorf("GetReleaseByID: %v", err)
  359. }
  360. repo, err := GetRepositoryByID(rel.RepoID)
  361. if err != nil {
  362. return fmt.Errorf("GetRepositoryByID: %v", err)
  363. }
  364. if delTag {
  365. _, stderr, err := process.GetManager().ExecDir(-1, repo.RepoPath(),
  366. fmt.Sprintf("DeleteReleaseByID (git tag -d): %d", rel.ID),
  367. "git", "tag", "-d", rel.TagName)
  368. if err != nil && !strings.Contains(stderr, "not found") {
  369. return fmt.Errorf("git tag -d: %v - %s", err, stderr)
  370. }
  371. if _, err = x.ID(rel.ID).Delete(new(Release)); err != nil {
  372. return fmt.Errorf("Delete: %v", err)
  373. }
  374. } else {
  375. rel.IsTag = true
  376. rel.IsDraft = false
  377. rel.IsPrerelease = false
  378. rel.Title = ""
  379. rel.Note = ""
  380. if _, err = x.ID(rel.ID).AllCols().Update(rel); err != nil {
  381. return fmt.Errorf("Update: %v", err)
  382. }
  383. }
  384. rel.Repo = repo
  385. if err = rel.LoadAttributes(); err != nil {
  386. return fmt.Errorf("LoadAttributes: %v", err)
  387. }
  388. mode, _ := AccessLevel(u, rel.Repo)
  389. if err := PrepareWebhooks(rel.Repo, HookEventRelease, &api.ReleasePayload{
  390. Action: api.HookReleaseDeleted,
  391. Release: rel.APIFormat(),
  392. Repository: rel.Repo.APIFormat(mode),
  393. Sender: rel.Publisher.APIFormat(),
  394. }); err != nil {
  395. log.Error(2, "PrepareWebhooks: %v", err)
  396. } else {
  397. go HookQueue.Add(rel.Repo.ID)
  398. }
  399. return nil
  400. }
  401. // SyncReleasesWithTags synchronizes release table with repository tags
  402. func SyncReleasesWithTags(repo *Repository, gitRepo *git.Repository) error {
  403. existingRelTags := make(map[string]struct{})
  404. opts := FindReleasesOptions{IncludeDrafts: true, IncludeTags: true}
  405. for page := 1; ; page++ {
  406. rels, err := GetReleasesByRepoID(repo.ID, opts, page, 100)
  407. if err != nil {
  408. return fmt.Errorf("GetReleasesByRepoID: %v", err)
  409. }
  410. if len(rels) == 0 {
  411. break
  412. }
  413. for _, rel := range rels {
  414. if rel.IsDraft {
  415. continue
  416. }
  417. commitID, err := gitRepo.GetTagCommitID(rel.TagName)
  418. if err != nil {
  419. return fmt.Errorf("GetTagCommitID: %v", err)
  420. }
  421. if !gitRepo.IsTagExist(rel.TagName) || commitID != rel.Sha1 {
  422. if err := pushUpdateDeleteTag(repo, gitRepo, rel.TagName); err != nil {
  423. return fmt.Errorf("pushUpdateDeleteTag: %v", err)
  424. }
  425. } else {
  426. existingRelTags[strings.ToLower(rel.TagName)] = struct{}{}
  427. }
  428. }
  429. }
  430. tags, err := gitRepo.GetTags()
  431. if err != nil {
  432. return fmt.Errorf("GetTags: %v", err)
  433. }
  434. for _, tagName := range tags {
  435. if _, ok := existingRelTags[strings.ToLower(tagName)]; !ok {
  436. if err := pushUpdateAddTag(repo, gitRepo, tagName); err != nil {
  437. return fmt.Errorf("pushUpdateAddTag: %v", err)
  438. }
  439. }
  440. }
  441. return nil
  442. }