Skip to content

Commit 6413862

Browse files
committed
fix lint
1 parent a1c0ee9 commit 6413862

File tree

5 files changed

+33
-33
lines changed

5 files changed

+33
-33
lines changed

modules/cron/cron.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ func NewContext() {
2424
err error
2525
)
2626
if setting.Cron.UpdateMirror.Enabled {
27-
entry, err = c.AddFunc("Update mirrors", setting.Cron.UpdateMirror.Schedule, mirror.MirrorUpdate)
27+
entry, err = c.AddFunc("Update mirrors", setting.Cron.UpdateMirror.Schedule, mirror.Update)
2828
if err != nil {
2929
log.Fatal(4, "Cron[Update mirrors]: %v", err)
3030
}
3131
if setting.Cron.UpdateMirror.RunAtStart {
3232
entry.Prev = time.Now()
3333
entry.ExecTimes++
34-
go mirror.MirrorUpdate()
34+
go mirror.Update()
3535
}
3636
}
3737
if setting.Cron.RepoHealthCheck.Enabled {

modules/mirror/action.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ import (
1414
api "code.gitea.io/sdk/gitea"
1515
)
1616

17-
// MirrorSyncPushActionOptions mirror synchronization action options.
18-
type MirrorSyncPushActionOptions struct {
17+
// SyncPushActionOptions mirror synchronization action options.
18+
type SyncPushActionOptions struct {
1919
RefName string
2020
OldCommitID string
2121
NewCommitID string
2222
Commits *models.PushCommits
2323
}
2424

25-
// MirrorSyncPushAction adds new action for mirror synchronization of pushed commits.
26-
func MirrorSyncPushAction(repo *models.Repository, opts MirrorSyncPushActionOptions) error {
25+
// SyncPushAction adds new action for mirror synchronization of pushed commits.
26+
func SyncPushAction(repo *models.Repository, opts SyncPushActionOptions) error {
2727
if len(opts.Commits.Commits) > setting.UI.FeedMaxCommitNum {
2828
opts.Commits.Commits = opts.Commits.Commits[:setting.UI.FeedMaxCommitNum]
2929
}
@@ -54,14 +54,14 @@ func MirrorSyncPushAction(repo *models.Repository, opts MirrorSyncPushActionOpti
5454
return nil
5555
}
5656

57-
// MirrorSyncCreateAction adds new action for mirror synchronization of new reference.
58-
func MirrorSyncCreateAction(repo *models.Repository, refName string) error {
57+
// SyncCreateAction adds new action for mirror synchronization of new reference.
58+
func SyncCreateAction(repo *models.Repository, refName string) error {
5959
notification.NotifyRepoMirrorSync(models.ActionMirrorSyncCreate, repo, refName, nil)
6060
return nil
6161
}
6262

63-
// MirrorSyncDeleteAction adds new action for mirror synchronization of delete reference.
64-
func MirrorSyncDeleteAction(repo *models.Repository, refName string) error {
63+
// SyncDeleteAction adds new action for mirror synchronization of delete reference.
64+
func SyncDeleteAction(repo *models.Repository, refName string) error {
6565
notification.NotifyRepoMirrorSync(models.ActionMirrorSyncDelete, repo, refName, nil)
6666
return nil
6767
}

modules/mirror/sync.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,27 @@ import (
2222
)
2323

2424
const (
25-
mirrorUpdate = "mirror_update"
25+
updateCronName = "mirror_update"
2626
)
2727

28-
// MirrorQueue holds an UniqueQueue object of the mirror
29-
var MirrorQueue = sync.NewUniqueQueue(setting.Repository.MirrorQueueLength)
28+
// Queue holds an UniqueQueue object of the mirror
29+
var Queue = sync.NewUniqueQueue(setting.Repository.MirrorQueueLength)
3030

3131
// gitShortEmptySha Git short empty SHA
3232
const gitShortEmptySha = "0000000"
3333

34-
// mirrorSyncResult contains information of a updated reference.
34+
// syncResult contains information of a updated reference.
3535
// If the oldCommitID is "0000000", it means a new reference, the value of newCommitID is empty.
3636
// If the newCommitID is "0000000", it means the reference is deleted, the value of oldCommitID is empty.
37-
type mirrorSyncResult struct {
37+
type syncResult struct {
3838
refName string
3939
oldCommitID string
4040
newCommitID string
4141
}
4242

4343
// parseRemoteUpdateOutput detects create, update and delete operations of references from upstream.
44-
func parseRemoteUpdateOutput(output string) []*mirrorSyncResult {
45-
results := make([]*mirrorSyncResult, 0, 3)
44+
func parseRemoteUpdateOutput(output string) []*syncResult {
45+
results := make([]*syncResult, 0, 3)
4646
lines := strings.Split(output, "\n")
4747
for i := range lines {
4848
// Make sure reference name is presented before continue
@@ -55,12 +55,12 @@ func parseRemoteUpdateOutput(output string) []*mirrorSyncResult {
5555

5656
switch {
5757
case strings.HasPrefix(lines[i], " * "): // New reference
58-
results = append(results, &mirrorSyncResult{
58+
results = append(results, &syncResult{
5959
refName: refName,
6060
oldCommitID: gitShortEmptySha,
6161
})
6262
case strings.HasPrefix(lines[i], " - "): // Delete reference
63-
results = append(results, &mirrorSyncResult{
63+
results = append(results, &syncResult{
6464
refName: refName,
6565
newCommitID: gitShortEmptySha,
6666
})
@@ -75,7 +75,7 @@ func parseRemoteUpdateOutput(output string) []*mirrorSyncResult {
7575
log.Error(2, "Expect two SHAs but not what found: %q", lines[i])
7676
continue
7777
}
78-
results = append(results, &mirrorSyncResult{
78+
results = append(results, &syncResult{
7979
refName: refName,
8080
oldCommitID: shas[0],
8181
newCommitID: shas[1],
@@ -109,7 +109,7 @@ func sanitizeOutput(output, repoPath string) (string, error) {
109109
}
110110

111111
// runSync returns true if sync finished without error.
112-
func runSync(m *models.Mirror) ([]*mirrorSyncResult, bool) {
112+
func runSync(m *models.Mirror) ([]*syncResult, bool) {
113113
repoPath := m.Repo.RepoPath()
114114
wikiPath := m.Repo.UncycloPath()
115115
timeout := time.Duration(setting.Git.Timeout.Mirror) * time.Second
@@ -186,12 +186,12 @@ func runSync(m *models.Mirror) ([]*mirrorSyncResult, bool) {
186186
return parseRemoteUpdateOutput(output), true
187187
}
188188

189-
// MirrorUpdate checks and updates mirror repositories.
190-
func MirrorUpdate() {
191-
if !models.TaskStartIfNotRunning(mirrorUpdate) {
189+
// Update checks and updates mirror repositories.
190+
func Update() {
191+
if !models.TaskStartIfNotRunning(updateCronName) {
192192
return
193193
}
194-
defer models.TaskStop(mirrorUpdate)
194+
defer models.TaskStop(updateCronName)
195195

196196
log.Trace("Doing: MirrorUpdate")
197197

@@ -202,7 +202,7 @@ func MirrorUpdate() {
202202
return nil
203203
}
204204

205-
MirrorQueue.Add(m.RepoID)
205+
Queue.Add(m.RepoID)
206206
return nil
207207
}); err != nil {
208208
log.Error(4, "MirrorUpdate: %v", err)
@@ -213,9 +213,9 @@ func MirrorUpdate() {
213213
// TODO: sync more mirrors at same time.
214214
func SyncMirrors() {
215215
// Start listening on new sync requests.
216-
for repoID := range MirrorQueue.Queue() {
216+
for repoID := range Queue.Queue() {
217217
log.Trace("SyncMirrors [repo_id: %v]", repoID)
218-
MirrorQueue.Remove(repoID)
218+
Queue.Remove(repoID)
219219

220220
m, err := models.GetMirrorByRepoID(com.StrTo(repoID).MustInt64())
221221
if err != nil {
@@ -253,15 +253,15 @@ func SyncMirrors() {
253253

254254
// Create reference
255255
if result.oldCommitID == gitShortEmptySha {
256-
if err = MirrorSyncCreateAction(m.Repo, result.refName); err != nil {
256+
if err = SyncCreateAction(m.Repo, result.refName); err != nil {
257257
log.Error(2, "MirrorSyncCreateAction [repo_id: %d]: %v", m.RepoID, err)
258258
}
259259
continue
260260
}
261261

262262
// Delete reference
263263
if result.newCommitID == gitShortEmptySha {
264-
if err = MirrorSyncDeleteAction(m.Repo, result.refName); err != nil {
264+
if err = SyncDeleteAction(m.Repo, result.refName); err != nil {
265265
log.Error(2, "MirrorSyncDeleteAction [repo_id: %d]: %v", m.RepoID, err)
266266
}
267267
continue
@@ -283,7 +283,7 @@ func SyncMirrors() {
283283
log.Error(2, "CommitsBetweenIDs [repo_id: %d, new_commit_id: %s, old_commit_id: %s]: %v", m.RepoID, newCommitID, oldCommitID, err)
284284
continue
285285
}
286-
if err = MirrorSyncPushAction(m.Repo, MirrorSyncPushActionOptions{
286+
if err = SyncPushAction(m.Repo, SyncPushActionOptions{
287287
RefName: result.refName,
288288
OldCommitID: oldCommitID,
289289
NewCommitID: newCommitID,

routers/api/v1/repo/repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ func MirrorSync(ctx *context.APIContext) {
568568
ctx.Error(403, "MirrorSync", "Must have write access")
569569
}
570570

571-
go mirror.MirrorQueue.Add(repo.ID)
571+
go mirror.Queue.Add(repo.ID)
572572
ctx.Status(200)
573573
}
574574

routers/repo/setting.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
154154
return
155155
}
156156

157-
go mirror.MirrorQueue.Add(repo.ID)
157+
go mirror.Queue.Add(repo.ID)
158158
ctx.Flash.Info(ctx.Tr("repo.settings.mirror_sync_in_progress"))
159159
ctx.Redirect(repo.Link() + "/settings")
160160

0 commit comments

Comments
 (0)