3cf9b6b913f2ff721a442001c200e3f9036c1675

Author
Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

fix: increase clone timeout, fix some lint issues

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

Diff

 1diff --git a/git/repo.go b/git/repo.go
 2index e91df362e4558b87ab00ae8a89c5e5c59d2ffd2a..050d3f67fd85a53766ce7b7de5f4311bc3563b9e 100644
 3--- a/git/repo.go
 4+++ b/git/repo.go
 5@@ -41,16 +41,6 @@ func Init(path string, bare bool) (*Repository, error) {
 6 	return Open(path)
 7 }
 8 
 9-func isInsideWorkTree(r *git.Repository) bool {
10-	out, err := r.RevParse("--is-inside-work-tree")
11-	return err == nil && out == "true"
12-}
13-
14-func isInsideGitDir(r *git.Repository) bool {
15-	out, err := r.RevParse("--is-inside-git-dir")
16-	return err == nil && out == "true"
17-}
18-
19 func gitDir(r *git.Repository) (string, error) {
20 	return r.RevParse("--git-dir")
21 }
22@@ -192,7 +182,7 @@ func (r *Repository) Patch(commit *Commit) (string, error) {
23 
24 // CountCommits returns the number of commits in the repository.
25 func (r *Repository) CountCommits(ref *Reference) (int64, error) {
26-	return r.Repository.RevListCount([]string{ref.Name().String()})
27+	return r.RevListCount([]string{ref.Name().String()})
28 }
29 
30 // CommitsByPage returns the commits for a given page and size.
31diff --git a/server/backend/sqlite/sqlite.go b/server/backend/sqlite/sqlite.go
32index 8b0a0c98a359e9282e614cabc66dceb76e9a9f6f..1581d5939d1c72d315bf4ad3a411f8cf55ff9b23 100644
33--- a/server/backend/sqlite/sqlite.go
34+++ b/server/backend/sqlite/sqlite.go
35@@ -6,6 +6,7 @@ import (
36 	"os"
37 	"path/filepath"
38 	"strings"
39+	"time"
40 
41 	"github.com/charmbracelet/log"
42 	"github.com/charmbracelet/soft-serve/git"
43@@ -14,12 +15,12 @@ import (
44 	"github.com/charmbracelet/soft-serve/server/hooks"
45 	"github.com/charmbracelet/soft-serve/server/utils"
46 	"github.com/jmoiron/sqlx"
47-	_ "modernc.org/sqlite"
48+	_ "modernc.org/sqlite" // sqlite driver
49 )
50 
51 // SqliteBackend is a backend that uses a SQLite database as a Soft Serve
52 // backend.
53-type SqliteBackend struct {
54+type SqliteBackend struct { //nolint: revive
55 	cfg    *config.Config
56 	ctx    context.Context
57 	dp     string
58@@ -177,9 +178,10 @@ func (d *SqliteBackend) ImportRepository(name string, remote string, opts backen
59 	rp := filepath.Join(d.reposPath(), repo)
60 
61 	copts := git.CloneOptions{
62-		Bare:   true,
63-		Mirror: opts.Mirror,
64-		Quiet:  true,
65+		Bare:    true,
66+		Mirror:  opts.Mirror,
67+		Quiet:   true,
68+		Timeout: 15 * time.Minute,
69 		CommandOptions: git.CommandOptions{
70 			Envs: []string{
71 				fmt.Sprintf(`GIT_SSH_COMMAND=ssh -o UserKnownHostsFile="%s" -o StrictHostKeyChecking=no -i "%s"`,