mirror of
https://github.com/thomiceli/opengist.git
synced 2024-12-23 13:02:39 +00:00
nits to improve git backend (#7)
This commit is contained in:
parent
31aae8a305
commit
19db4c223b
3 changed files with 7 additions and 5 deletions
|
@ -7,6 +7,7 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -62,8 +63,9 @@ func GetFilesOfRepository(user string, gist string, revision string) ([]string,
|
||||||
cmd := exec.Command(
|
cmd := exec.Command(
|
||||||
"git",
|
"git",
|
||||||
"ls-tree",
|
"ls-tree",
|
||||||
revision,
|
|
||||||
"--name-only",
|
"--name-only",
|
||||||
|
"--",
|
||||||
|
revision,
|
||||||
)
|
)
|
||||||
cmd.Dir = repositoryPath
|
cmd.Dir = repositoryPath
|
||||||
|
|
||||||
|
@ -101,7 +103,7 @@ func GetFileContent(user string, gist string, revision string, filename string,
|
||||||
return truncateCommandOutput(stdout, maxBytes)
|
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)
|
repositoryPath := RepositoryPath(user, gist)
|
||||||
|
|
||||||
cmd := exec.Command(
|
cmd := exec.Command(
|
||||||
|
@ -113,7 +115,7 @@ func GetLog(user string, gist string, skip string) ([]*Commit, error) {
|
||||||
"--no-color",
|
"--no-color",
|
||||||
"-p",
|
"-p",
|
||||||
"--skip",
|
"--skip",
|
||||||
skip,
|
strconv.Itoa(skip),
|
||||||
"--format=format:c %H%na %aN%nm %ae%nt %at",
|
"--format=format:c %H%na %aN%nm %ae%nt %at",
|
||||||
"--shortstat",
|
"--shortstat",
|
||||||
"HEAD",
|
"HEAD",
|
||||||
|
|
|
@ -228,7 +228,7 @@ func (gist *Gist) File(revision string, filename string, truncate bool) (*git.Fi
|
||||||
}, err
|
}, 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)
|
return git.GetLog(gist.User.Username, gist.Uuid, skip)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ func revisions(ctx echo.Context) error {
|
||||||
|
|
||||||
pageInt := getPage(ctx)
|
pageInt := getPage(ctx)
|
||||||
|
|
||||||
commits, err := gist.Log(strconv.Itoa((pageInt - 1) * 10))
|
commits, err := gist.Log((pageInt - 1) * 10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errorRes(500, "Error fetching commits log", err)
|
return errorRes(500, "Error fetching commits log", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue