From e120fdb97e3af76198eadc8a44e6feb732b4dd83 Mon Sep 17 00:00:00 2001 From: Steve Moyer Date: Thu, 26 May 2022 13:39:13 -0400 Subject: refactor: use namespace instead of application of applicationName --- repository/gogit.go | 38 +++++++++++++++++++------------------- repository/gogit_testing.go | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) (limited to 'repository') diff --git a/repository/gogit.go b/repository/gogit.go index e876629a..46a2cb0a 100644 --- a/repository/gogit.go +++ b/repository/gogit.go @@ -50,11 +50,11 @@ type GoGitRepo struct { localStorage billy.Filesystem } -// OpenGoGitRepo opens an already existing repo at the given path and with -// the specified application name. Given a repository path of "~/myrepo" -// and an application name of "git-bug", local storage for the application -// will be configured at "~/myrepo/.git/git-bug". -func OpenGoGitRepo(path, application string, clockLoaders []ClockLoader) (*GoGitRepo, error) { +// OpenGoGitRepo opens an already existing repo at the given path and +// with the specified LocalStorage namespace. Given a repository path +// of "~/myrepo" and a namespace of "git-bug", local storage for the +// GoGitRepo will be configured at "~/myrepo/.git/git-bug". +func OpenGoGitRepo(path, namespace string, clockLoaders []ClockLoader) (*GoGitRepo, error) { path, err := detectGitPath(path) if err != nil { return nil, err @@ -76,7 +76,7 @@ func OpenGoGitRepo(path, application string, clockLoaders []ClockLoader) (*GoGit clocks: make(map[string]lamport.Clock), indexes: make(map[string]bleve.Index), keyring: k, - localStorage: osfs.New(filepath.Join(path, application)), + localStorage: osfs.New(filepath.Join(path, namespace)), } for _, loader := range clockLoaders { @@ -98,11 +98,11 @@ func OpenGoGitRepo(path, application string, clockLoaders []ClockLoader) (*GoGit return repo, nil } -// InitGoGitRepo creates a new empty git repo at the given path and with -// the specified application name. Given a repository path of "~/myrepo" -// and an application name of "git-bug", local storage for the application -// will be configured at "~/myrepo/.git/git-bug". -func InitGoGitRepo(path, application string) (*GoGitRepo, error) { +// InitGoGitRepo creates a new empty git repo at the given path and +// with the specified LocalStorage namespace. Given a repository path +// of "~/myrepo" and a namespace of "git-bug", local storage for the +// GoGitRepo will be configured at "~/myrepo/.git/git-bug". +func InitGoGitRepo(path, namespace string) (*GoGitRepo, error) { r, err := gogit.PlainInit(path, false) if err != nil { return nil, err @@ -119,15 +119,15 @@ func InitGoGitRepo(path, application string) (*GoGitRepo, error) { clocks: make(map[string]lamport.Clock), indexes: make(map[string]bleve.Index), keyring: k, - localStorage: osfs.New(filepath.Join(path, ".git", application)), + localStorage: osfs.New(filepath.Join(path, ".git", namespace)), }, nil } -// InitBareGoGitRepo creates a new --bare empty git repo at the given path -// and with the specified application name. Given a repository path of -// "~/myrepo" and an application name of "git-bug", local storage for the -// application will be configured at "~/myrepo/.git/git-bug". -func InitBareGoGitRepo(path, application string) (*GoGitRepo, error) { +// InitBareGoGitRepo creates a new --bare empty git repo at the given +// path and with the specified LocalStorage namespace. Given a repository +// path of "~/myrepo" and a namespace of "git-bug", local storage for the +// GoGitRepo will be configured at "~/myrepo/.git/git-bug". +func InitBareGoGitRepo(path, namespace string) (*GoGitRepo, error) { r, err := gogit.PlainInit(path, true) if err != nil { return nil, err @@ -144,7 +144,7 @@ func InitBareGoGitRepo(path, application string) (*GoGitRepo, error) { clocks: make(map[string]lamport.Clock), indexes: make(map[string]bleve.Index), keyring: k, - localStorage: osfs.New(filepath.Join(path, application)), + localStorage: osfs.New(filepath.Join(path, namespace)), }, nil } @@ -306,7 +306,7 @@ func (repo *GoGitRepo) GetRemotes() (map[string]string, error) { } // LocalStorage returns a billy.Filesystem giving access to -// $RepoPath/.git/$ApplicationName. +// $RepoPath/.git/$Namespace. func (repo *GoGitRepo) LocalStorage() billy.Filesystem { return repo.localStorage } diff --git a/repository/gogit_testing.go b/repository/gogit_testing.go index f80f62c0..7647c711 100644 --- a/repository/gogit_testing.go +++ b/repository/gogit_testing.go @@ -7,7 +7,7 @@ import ( "github.com/99designs/keyring" ) -const testApplicationName = "git-bug" +const namespace = "git-bug" // This is intended for testing only @@ -25,7 +25,7 @@ func CreateGoGitTestRepo(bare bool) TestedRepo { creator = InitGoGitRepo } - repo, err := creator(dir, testApplicationName) + repo, err := creator(dir, namespace) if err != nil { log.Fatal(err) } -- cgit