Skip to content

Commit 77981cb

Browse files
committed
remove logic that calculates relative commit time
1 parent 6c21067 commit 77981cb

File tree

7 files changed

+24
-111
lines changed

7 files changed

+24
-111
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,3 @@ For reporting issues or for requesting any feature use the following medium,
146146

147147
See [LICENSE ](LICENSE) info for more
148148

149-

git/git_commit_logs.go

Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import (
77
"github.com/go-git/go-git/v5/plumbing/object"
88
"github.com/neel1996/gitconvex-server/global"
99
"github.com/neel1996/gitconvex-server/graph/model"
10-
"github.com/nleeper/goment"
1110
"go/types"
12-
"strconv"
1311
"strings"
1412
"time"
1513
)
@@ -26,7 +24,6 @@ func commitOrganizer(commits []object.Commit) []*model.GitCommits {
2624
commitFilesItr, err := commit.Files()
2725
commitFileCount := 0
2826
commitDate := ""
29-
commitRelativeTime := ""
3027

3128
logger.Log(fmt.Sprintf("Fetching commit details for -> %s", commitHash), global.StatusInfo)
3229

@@ -61,47 +58,6 @@ func commitOrganizer(commits []object.Commit) []*model.GitCommits {
6158
logger.Log(convErr.Error(), global.StatusError)
6259
} else {
6360
commitDate = cTime.String()
64-
gTime, gTimeErr := goment.New(cTime)
65-
if gTimeErr != nil {
66-
logger.Log(gTimeErr.Error(), global.StatusError)
67-
} else {
68-
commitRelativeTime = gTime.FromNow()
69-
70-
// Conditional logic to find time diff to bypass goment bug
71-
if strings.Contains(commitRelativeTime, "in") {
72-
aTime := time.Now().String()
73-
74-
a, _ := time.Parse("2006-01-02 15:04:05", aTime[:19])
75-
b, _ := time.Parse("2006-01-02 15:04:05", cTime.String()[:19])
76-
diff := a.Sub(b)
77-
78-
h := diff.Hours()
79-
m := diff.Minutes()
80-
s := diff.Seconds()
81-
82-
if h != float64(0) {
83-
hStr := strconv.Itoa(int(h))
84-
if hStr == "1" {
85-
commitRelativeTime = hStr + " hour ago"
86-
} else {
87-
commitRelativeTime = hStr + " hours ago"
88-
}
89-
} else {
90-
if m != float64(0) {
91-
mStr := strconv.Itoa(int(m))
92-
commitRelativeTime = mStr + " minutes ago"
93-
} else {
94-
if s != float64(0) {
95-
sStr := strconv.Itoa(int(s))
96-
commitRelativeTime = sStr + " seconds ago"
97-
} else {
98-
commitRelativeTime = "recent commit"
99-
100-
}
101-
}
102-
}
103-
}
104-
}
10561
}
10662
}
10763
}
@@ -115,12 +71,11 @@ func commitOrganizer(commits []object.Commit) []*model.GitCommits {
11571
}
11672

11773
commitList = append(commitList, &model.GitCommits{
118-
Hash: &commitHash,
119-
Author: &commitAuthor,
120-
CommitTime: &commitDate,
121-
CommitMessage: &commitMessage,
122-
CommitRelativeTime: &commitRelativeTime,
123-
CommitFilesCount: &commitFileCount,
74+
Hash: &commitHash,
75+
Author: &commitAuthor,
76+
CommitTime: &commitDate,
77+
CommitMessage: &commitMessage,
78+
CommitFilesCount: &commitFileCount,
12479
})
12580
}
12681
}

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ require (
88
github.com/go-git/go-git/v5 v5.2.0
99
github.com/google/uuid v1.1.2
1010
github.com/gorilla/mux v1.8.0
11-
github.com/nleeper/goment v1.4.0
1211
github.com/rs/cors v1.7.0
1312
github.com/vektah/gqlparser/v2 v2.1.0
1413
)

graph/generated/generated.go

Lines changed: 5 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

graph/model/models_gen.go

Lines changed: 5 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

graph/schema.graphqls

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ type gitCommits {
4848
author: String
4949
commitTime: String
5050
commitMessage: String
51-
commitRelativeTime: String
5251
commitFilesCount: Int
5352
}
5453

graph/schema.resolvers.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ package graph
55

66
import (
77
"context"
8-
"github.com/neel1996/gitconvex-server/global"
98

109
"github.com/neel1996/gitconvex-server/api"
1110
"github.com/neel1996/gitconvex-server/git"
11+
"github.com/neel1996/gitconvex-server/global"
1212
"github.com/neel1996/gitconvex-server/graph/generated"
1313
"github.com/neel1996/gitconvex-server/graph/model"
1414
)
1515

16-
var logger global.Logger
17-
1816
func (r *mutationResolver) AddRepo(ctx context.Context, repoName string, repoPath string, cloneSwitch bool, repoURL *string, initSwitch bool, authOption string, userName *string, password *string) (*model.AddRepoParams, error) {
1917
return api.AddRepo(model.NewRepoInputs{
2018
RepoName: repoName,
@@ -304,7 +302,6 @@ func (r *queryResolver) SearchCommitLogs(ctx context.Context, repoID string, sea
304302
Author: nil,
305303
CommitTime: nil,
306304
CommitMessage: nil,
307-
CommitRelativeTime: nil,
308305
CommitFilesCount: nil,
309306
},
310307
}, nil
@@ -430,3 +427,11 @@ func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} }
430427

431428
type mutationResolver struct{ *Resolver }
432429
type queryResolver struct{ *Resolver }
430+
431+
// !!! WARNING !!!
432+
// The code below was going to be deleted when updating resolvers. It has been copied here so you have
433+
// one last chance to move it out of harms way if you want. There are two reasons this happens:
434+
// - When renaming or deleting a resolver the old code will be put in here. You can safely delete
435+
// it when you're done.
436+
// - You have helper methods in this file. Move them out to keep these resolver files clean.
437+
var logger global.Logger

0 commit comments

Comments
 (0)