Skip to content

Commit 2304a5d

Browse files
committed
Format everything with gofmt
1 parent d293f24 commit 2304a5d

File tree

6 files changed

+18
-24
lines changed

6 files changed

+18
-24
lines changed

models/contributors/contributors_graph.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import (
1313

1414
type WeekData struct {
1515
Week int64 `json:"week"`
16-
Additions int `json:"additions"`
17-
Deletions int `json:"deletions"`
18-
Commits int `json:"commits"`
16+
Additions int `json:"additions"`
17+
Deletions int `json:"deletions"`
18+
Commits int `json:"commits"`
1919
}
2020

2121
// ContributorData represents statistical git commit count data
@@ -59,7 +59,6 @@ func GetContributorStats(ctx context.Context, repo *repo_model.Repository) (map[
5959
layout := "2006-01-02"
6060
initial_commit_date := extended_commit_stats[0].Author.Date
6161

62-
6362
starting_sunday, _ := util.FindLastSundayBeforeDate(initial_commit_date)
6463
ending_sunday, _ := util.FindFirstSundayAfterDate(time.Now().Format(layout))
6564

@@ -100,9 +99,9 @@ func GetContributorStats(ctx context.Context, repo *repo_model.Repository) (map[
10099
user, _ := contributors_commit_stats[v.Author.Email]
101100
starting_of_week, _ := util.FindLastSundayBeforeDate(v.Author.Date)
102101

103-
val, _ := time.Parse(layout, starting_of_week)
102+
val, _ := time.Parse(layout, starting_of_week)
104103
starting_sunday_p, _ := time.Parse(layout, starting_sunday)
105-
idx := int(val.Sub(starting_sunday_p).Hours()/24)/7
104+
idx := int(val.Sub(starting_sunday_p).Hours()/24) / 7
106105
user.Weeks[idx].Additions += v.Stats.Additions
107106
user.Weeks[idx].Deletions += v.Stats.Deletions
108107
user.Weeks[idx].Commits++

modules/git/repo_commit.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import (
1515
"strconv"
1616
"strings"
1717

18-
api "code.gitea.io/gitea/modules/structs"
1918
"code.gitea.io/gitea/modules/cache"
2019
"code.gitea.io/gitea/modules/setting"
20+
api "code.gitea.io/gitea/modules/structs"
2121
)
2222

2323
// GetBranchCommitID returns last commit ID string of given branch.
@@ -224,7 +224,6 @@ type CommitsByFileAndRangeOptions struct {
224224
Page int
225225
}
226226

227-
228227
// ExtendedCommitStats return the list of *api.ExtendedCommitStats for the given revision
229228
func (repo *Repository) ExtendedCommitStats(revision string, limit int) ([]*api.ExtendedCommitStats, error) {
230229
var baseCommit *Commit
@@ -239,10 +238,9 @@ func (repo *Repository) ExtendedCommitStats(revision string, limit int) ([]*api.
239238
}()
240239

241240
gitCmd := NewCommand(repo.Ctx, "log", "--shortstat", "--no-merges", "--pretty=format:%aN%n%aE%n%as", "--reverse")
242-
// AddOptionFormat("--max-count=%d", limit)
241+
// AddOptionFormat("--max-count=%d", limit)
243242
gitCmd.AddDynamicArguments(baseCommit.ID.String())
244243

245-
246244
var extended_commit_stats []*api.ExtendedCommitStats
247245
stderr := new(strings.Builder)
248246
err = gitCmd.Run(&RunOpts{
@@ -290,7 +288,7 @@ func (repo *Repository) ExtendedCommitStats(revision string, limit int) ([]*api.
290288
res := &api.ExtendedCommitStats{
291289
Author: &api.CommitUser{
292290
Identity: api.Identity{
293-
Name: author_name,
291+
Name: author_name,
294292
Email: author_email,
295293
},
296294
Date: date,
@@ -299,7 +297,7 @@ func (repo *Repository) ExtendedCommitStats(revision string, limit int) ([]*api.
299297
}
300298
extended_commit_stats = append(extended_commit_stats, res)
301299

302-
}
300+
}
303301
_ = stdoutReader.Close()
304302
return nil
305303
},

modules/structs/repo_commit.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ type Commit struct {
6060

6161
// ExtendedCommitStats contains information for commit stats with author data
6262
type ExtendedCommitStats struct {
63-
Author *CommitUser `json:"author"`
64-
Stats *CommitStats `json:"stats"`
63+
Author *CommitUser `json:"author"`
64+
Stats *CommitStats `json:"stats"`
6565
}
6666

6767
// CommitDateOptions store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE

modules/util/dates.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ func FindLastSundayBeforeDate(dateStr string) (string, error) {
4949
return last_sunday.Format(layout), nil
5050
}
5151

52-
5352
func FindFirstSundayAfterDate(dateStr string) (string, error) {
5453
layout := "2006-01-02"
5554

@@ -59,10 +58,10 @@ func FindFirstSundayAfterDate(dateStr string) (string, error) {
5958
}
6059

6160
weekday := date.Weekday()
62-
daysToAdd := int(time.Sunday) - int(weekday)
63-
if daysToAdd <= 0 {
64-
daysToAdd += 7
65-
}
61+
daysToAdd := int(time.Sunday) - int(weekday)
62+
if daysToAdd <= 0 {
63+
daysToAdd += 7
64+
}
6665

6766
first_sunday := date.AddDate(0, 0, daysToAdd)
6867
return first_sunday.Format(layout), nil

routers/api/v1/repo/commits.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ func GetAllCommits(ctx *context.APIContext) {
279279
ctx.JSON(http.StatusOK, &apiCommits)
280280
}
281281

282-
283282
// GetAllCommitsStats get all commits via
284283
func GetAllCommitsStats(ctx *context.APIContext) {
285284
// swagger:operation GET /repos/{owner}/{repo}/commits/stats repository repoGetAllCommitsStats
@@ -321,8 +320,8 @@ func GetAllCommitsStats(ctx *context.APIContext) {
321320
sha := ctx.FormString("sha")
322321

323322
var (
324-
commits []*api.ExtendedCommitStats
325-
err error
323+
commits []*api.ExtendedCommitStats
324+
err error
326325
)
327326

328327
if len(sha) == 0 {

routers/web/repo/contributors.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func Contributors(ctx *context.Context) {
2929
if contributor_stats, err := contributors_model.GetContributorStats(ctx, ctx.Repo.Repository); err != nil {
3030
ctx.ServerError("GetContributorStats", err)
3131
return
32-
} else{
32+
} else {
3333
ctx.PageData["repoContributorsCommitStats"] = contributor_stats
3434
timeUntil := time.Now()
3535
timeFrom := time.UnixMilli(contributor_stats[""].Weeks[0].Week)
@@ -39,6 +39,5 @@ func Contributors(ctx *context.Context) {
3939
// contributor_stats[""].Weeks.(map[string]interface{})
4040
}
4141

42-
4342
ctx.HTML(http.StatusOK, tplContributors)
4443
}

0 commit comments

Comments
 (0)