Skip to content

Commit f9aec50

Browse files
committed
NewRepositoryFromPath(): function renamed from NewRepository()
1 parent 02928f1 commit f9aec50

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

git-sizer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func mainImplementation(ctx context.Context, stdout, stderr io.Writer, args []st
134134

135135
// Try to open the repository, but it's not an error yet if this
136136
// fails, because the user might only be asking for `--help`.
137-
repo, repoErr := git.NewRepository(".")
137+
repo, repoErr := git.NewRepositoryFromPath(".")
138138

139139
flags := pflag.NewFlagSet("git-sizer", pflag.ContinueOnError)
140140
flags.Usage = func() {

git/git.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ func NewRepositoryFromGitDir(gitDir string) (*Repository, error) {
6565
return &repo, nil
6666
}
6767

68-
// NewRepository creates a new `Repository` object that can be used
69-
// for running `git` commands within `path`.
70-
func NewRepository(path string) (*Repository, error) {
71-
// Find the `git` executable to be used:
68+
// NewRepositoryFromPath creates a new `Repository` object that can be
69+
// used for running `git` commands within `path`. It does so by asking
70+
// `git` what `GIT_DIR` to use. Git, in turn, bases its decision on
71+
// the path and the environment.
72+
func NewRepositoryFromPath(path string) (*Repository, error) {
7273
gitBin, err := findGitBin()
7374
if err != nil {
7475
return nil, fmt.Errorf(

internal/testutils/repoutils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (repo *TestRepo) Clone(t *testing.T, pattern string) *TestRepo {
8989
func (repo *TestRepo) Repository(t *testing.T) *git.Repository {
9090
t.Helper()
9191

92-
r, err := git.NewRepository(repo.Path)
92+
r, err := git.NewRepositoryFromPath(repo.Path)
9393
require.NoError(t, err)
9494
return r
9595
}

0 commit comments

Comments
 (0)