Просмотр исходного кода

[fmt] Fix fmt issues with go master

cgars 6 лет назад
Родитель
Сommit
51718733bd
4 измененных файлов с 6 добавлено и 100 удалено
  1. 1 95
      models/mirror.go
  2. 3 3
      models/repo_editor.go
  3. 1 1
      routes/repo/setting.go
  4. 1 1
      routes/repo/view.go

+ 1 - 95
models/mirror.go

@@ -382,100 +382,6 @@ func SyncMirrors() {
 			continue
 			continue
 		}
 		}
 
 
-		// TODO:
-		// - Create "Mirror Sync" webhook event
-		// - Create mirror sync (create, push and delete) events and trigger the "mirror sync" webhooks
-
-		var gitRepo *git.Repository
-		if len(results) == 0 {
-			log.Trace("SyncMirrors [repo_id: %d]: no commits fetched", m.RepoID)
-		} else {
-			gitRepo, err = git.OpenRepository(m.Repo.RepoPath())
-			if err != nil {
-				log.Error(2, "OpenRepository [%d]: %v", m.RepoID, err)
-				continue
-			}
-		}
-
-		for _, result := range results {
-			// Discard GitHub pull requests, i.e. refs/pull/*
-			if strings.HasPrefix(result.refName, "refs/pull/") {
-				continue
-			}
-
-			// Delete reference
-			if result.newCommitID == GIT_SHORT_EMPTY_SHA {
-				if err = MirrorSyncDeleteAction(m.Repo, result.refName); err != nil {
-					log.Error(2, "MirrorSyncDeleteAction [repo_id: %d]: %v", m.RepoID, err)
-				}
-				continue
-			}
-
-			// New reference
-			isNewRef := false
-			if result.oldCommitID == GIT_SHORT_EMPTY_SHA {
-				if err = MirrorSyncCreateAction(m.Repo, result.refName); err != nil {
-					log.Error(2, "MirrorSyncCreateAction [repo_id: %d]: %v", m.RepoID, err)
-					continue
-				}
-				isNewRef = true
-			}
-
-			// Push commits
-			var commits *list.List
-			var oldCommitID string
-			var newCommitID string
-			if !isNewRef {
-				oldCommitID, err = git.GetFullCommitID(gitRepo.Path, result.oldCommitID)
-				if err != nil {
-					log.Error(2, "GetFullCommitID [%d]: %v", m.RepoID, err)
-					continue
-				}
-				newCommitID, err = git.GetFullCommitID(gitRepo.Path, result.newCommitID)
-				if err != nil {
-					log.Error(2, "GetFullCommitID [%d]: %v", m.RepoID, err)
-					continue
-				}
-				commits, err = gitRepo.CommitsBetweenIDs(newCommitID, oldCommitID)
-				if err != nil {
-					log.Error(2, "CommitsBetweenIDs [repo_id: %d, new_commit_id: %s, old_commit_id: %s]: %v", m.RepoID, newCommitID, oldCommitID, err)
-					continue
-				}
-			} else {
-				refNewCommitID, err := gitRepo.GetBranchCommitID(result.refName)
-				if err != nil {
-					log.Error(2, "GetFullCommitID [%d]: %v", m.RepoID, err)
-					continue
-				}
-				if newCommit, err := gitRepo.GetCommit(refNewCommitID); err != nil {
-					log.Error(2, "GetCommit [repo_id: %d, commit_id: %s]: %v", m.RepoID, refNewCommitID, err)
-					continue
-				} else {
-					// TODO: Get the commits for the new ref until the closest ancestor branch like Github does
-					commits, err = newCommit.CommitsBeforeLimit(10)
-					if err != nil {
-						log.Error(2, "CommitsBeforeLimit [repo_id: %d, commit_id: %s]: %v", m.RepoID, refNewCommitID, err)
-					}
-					oldCommitID = git.EMPTY_SHA
-					newCommitID = refNewCommitID
-				}
-			}
-			if err = MirrorSyncPushAction(m.Repo, MirrorSyncPushActionOptions{
-				RefName:     result.refName,
-				OldCommitID: oldCommitID,
-				NewCommitID: newCommitID,
-				Commits:     ListToPushCommits(commits),
-			}); err != nil {
-				log.Error(2, "MirrorSyncPushAction [repo_id: %d]: %v", m.RepoID, err)
-				continue
-			}
-		}
-
-		if _, err = x.Exec("UPDATE mirror SET updated_unix = ? WHERE repo_id = ?", time.Now().Unix(), m.RepoID); err != nil {
-			log.Error(2, "Update 'mirror.updated_unix' [%d]: %v", m.RepoID, err)
-			continue
-		}
-
 		// Get latest commit date and compare to current repository updated time,
 		// Get latest commit date and compare to current repository updated time,
 		// update if latest commit date is newer.
 		// update if latest commit date is newer.
 		commitDate, err := git.GetLatestCommitDate(m.Repo.RepoPath(), "")
 		commitDate, err := git.GetLatestCommitDate(m.Repo.RepoPath(), "")
@@ -487,7 +393,7 @@ func SyncMirrors() {
 		}
 		}
 
 
 		if _, err = x.Exec("UPDATE repository SET updated_unix = ? WHERE id = ?", commitDate.Unix(), m.RepoID); err != nil {
 		if _, err = x.Exec("UPDATE repository SET updated_unix = ? WHERE id = ?", commitDate.Unix(), m.RepoID); err != nil {
-			log.Error(2, "Update 'repository.updated_unix' [%d]: %v", m.RepoID, err)
+			log.Error(2, "Update repository 'updated_unix' [%d]: %v", m.RepoID, err)
 			continue
 			continue
 		}
 		}
 	}
 	}

+ 3 - 3
models/repo_editor.go

@@ -533,9 +533,9 @@ func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions)
 		if err = com.Copy(tmpPath, targetPath); err != nil {
 		if err = com.Copy(tmpPath, targetPath); err != nil {
 			return fmt.Errorf("copy: %v", err)
 			return fmt.Errorf("copy: %v", err)
 		}
 		}
-		log.Trace("Check for annexing: %s,%s", upload.Name)
+		log.Trace("Check for annexing: %s", upload.Name)
 		if finfo, err := os.Stat(targetPath); err == nil {
 		if finfo, err := os.Stat(targetPath); err == nil {
-			log.Trace("Filesize is:%s", finfo.Size())
+			log.Trace("Filesize is:%d", finfo.Size())
 			// Should we annex
 			// Should we annex
 			if finfo.Size() > setting.Repository.Upload.AnexFileMinSize*gannex.MEGABYTE {
 			if finfo.Size() > setting.Repository.Upload.AnexFileMinSize*gannex.MEGABYTE {
 				log.Trace("This file should be annexed: %s", upload.Name)
 				log.Trace("This file should be annexed: %s", upload.Name)
@@ -641,7 +641,7 @@ func StartIndexing(user, owner *User, repo *Repository) {
 	client := http.Client{}
 	client := http.Client{}
 	resp, err := client.Do(req)
 	resp, err := client.Do(req)
 	if err != nil || resp.StatusCode != http.StatusOK {
 	if err != nil || resp.StatusCode != http.StatusOK {
-		log.Trace("Error doing index request:%+v,%d", err)
+		log.Trace("Error doing index request:%+v", err)
 		return
 		return
 	}
 	}
 }
 }

+ 1 - 1
routes/repo/setting.go

@@ -384,7 +384,7 @@ func inviteWithMail(c *context.Context, mail string) (*models.User, error) {
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
-	log.Info("User: %s created", user.Name, pw)
+	log.Info("User: %s created", user.Name)
 	c.Context.Data["Account"] = user.Name
 	c.Context.Data["Account"] = user.Name
 	c.Context.Data["Inviter"] = c.User.Name
 	c.Context.Data["Inviter"] = c.User.Name
 	c.Context.Data["Pw"] = pw
 	c.Context.Data["Pw"] = pw

+ 1 - 1
routes/repo/view.go

@@ -184,7 +184,7 @@ func renderDirectory(c *context.Context, treeLink string) {
 func renderFile(c *context.Context, entry *git.TreeEntry, treeLink, rawLink string, cpt *captcha.Captcha) {
 func renderFile(c *context.Context, entry *git.TreeEntry, treeLink, rawLink string, cpt *captcha.Captcha) {
 	c.Data["IsViewFile"] = true
 	c.Data["IsViewFile"] = true
 	blob := entry.Blob()
 	blob := entry.Blob()
-	log.Trace("Blob size is %s", blob.Size())
+	log.Trace("Blob size is %d", blob.Size())
 	if blob.Size() > gannex.MEGABYTE*10 && setting.Service.EnableCaptcha && !cpt.VerifyReq(c.Req) && !c.IsLogged {
 	if blob.Size() > gannex.MEGABYTE*10 && setting.Service.EnableCaptcha && !cpt.VerifyReq(c.Req) && !c.IsLogged {
 		c.Data["EnableCaptcha"] = true
 		c.Data["EnableCaptcha"] = true
 		c.HTML(200, "repo/download")
 		c.HTML(200, "repo/download")