Skip to content

Commit

Permalink
fix(server): use canonical repos dir
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed May 2, 2023
1 parent 53ba263 commit 2625414
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 59 deletions.
5 changes: 5 additions & 0 deletions server/backend/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ func (fb *FileBackend) reposPath() string {
return filepath.Join(fb.path, repos)
}

// RepositoryStorePath returns the path to the repository store.
func (fb *FileBackend) RepositoryStorePath() string {
return fb.reposPath()
}

func (fb *FileBackend) settingsPath() string {
return filepath.Join(fb.path, settings)
}
Expand Down
2 changes: 2 additions & 0 deletions server/backend/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ type RepositoryStore interface {
Repository(repo string) (Repository, error)
// Repositories returns a list of all repositories.
Repositories() ([]Repository, error)
// RepositoryStorePath returns the path to the repository store.
RepositoryStorePath() string
// CreateRepository creates a new repository.
CreateRepository(name string, private bool) (Repository, error)
// DeleteRepository deletes a repository.
Expand Down
3 changes: 1 addition & 2 deletions server/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ func (d *GitDaemon) handleClient(conn net.Conn) {
// git bare repositories should end in ".git"
// https://git-scm.com/docs/gitrepository-layout
repo := name + ".git"
// FIXME: determine repositories path
reposDir := filepath.Join(d.cfg.DataPath, "repos")
reposDir := d.cfg.Backend.RepositoryStorePath()
if err := ensureWithin(reposDir, repo); err != nil {
fatal(c, err)
return
Expand Down
55 changes: 0 additions & 55 deletions server/git/daemon/conn.go

This file was deleted.

3 changes: 1 addition & 2 deletions server/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ func (s *SSHServer) Middleware(cfg *config.Config) wish.Middleware {
// https://git-scm.com/docs/gitrepository-layout
repo := name + ".git"

// FIXME: determine repositories path
reposDir := filepath.Join(cfg.DataPath, "repos")
reposDir := cfg.Backend.RepositoryStorePath()
if err := ensureWithin(reposDir, repo); err != nil {
sshFatal(s, err)
return
Expand Down

0 comments on commit 2625414

Please sign in to comment.