Skip to content

Commit

Permalink
nits to improve git backend (thomiceli#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 authored Apr 16, 2023
1 parent f297f26 commit 2e5e763
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions internal/git/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os/exec"
"path"
"path/filepath"
"strconv"
"strings"
)

Expand Down Expand Up @@ -62,8 +63,9 @@ func GetFilesOfRepository(user string, gist string, revision string) ([]string,
cmd := exec.Command(
"git",
"ls-tree",
revision,
"--name-only",
"--",
revision,
)
cmd.Dir = repositoryPath

Expand Down Expand Up @@ -101,7 +103,7 @@ func GetFileContent(user string, gist string, revision string, filename string,
return truncateCommandOutput(stdout, maxBytes)
}

func GetLog(user string, gist string, skip string) ([]*Commit, error) {
func GetLog(user string, gist string, skip int) ([]*Commit, error) {
repositoryPath := RepositoryPath(user, gist)

cmd := exec.Command(
Expand All @@ -113,7 +115,7 @@ func GetLog(user string, gist string, skip string) ([]*Commit, error) {
"--no-color",
"-p",
"--skip",
skip,
strconv.Itoa(skip),
"--format=format:c %H%na %aN%nm %ae%nt %at",
"--shortstat",
"HEAD",
Expand Down
2 changes: 1 addition & 1 deletion internal/models/gist.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (gist *Gist) File(revision string, filename string, truncate bool) (*git.Fi
}, err
}

func (gist *Gist) Log(skip string) ([]*git.Commit, error) {
func (gist *Gist) Log(skip int) ([]*git.Commit, error) {
return git.GetLog(gist.User.Username, gist.Uuid, skip)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/web/gist.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func revisions(ctx echo.Context) error {

pageInt := getPage(ctx)

commits, err := gist.Log(strconv.Itoa((pageInt - 1) * 10))
commits, err := gist.Log((pageInt - 1) * 10)
if err != nil {
return errorRes(500, "Error fetching commits log", err)
}
Expand Down

0 comments on commit 2e5e763

Please sign in to comment.