Skip to content

Commit

Permalink
fix: Fix handling of default refs in LiveRepoProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed May 24, 2022
1 parent 501b628 commit 8e181c3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
4 changes: 4 additions & 0 deletions pkg/git/mirrored_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ func NewMirroredGitRepo(ctx context.Context, u git_url.GitUrl) (*MirroredGitRepo
return o, nil
}

func (g *MirroredGitRepo) Url() git_url.GitUrl {
return g.url
}

func (g *MirroredGitRepo) HasUpdated() bool {
return g.hasUpdated
}
Expand Down
26 changes: 19 additions & 7 deletions pkg/git/repoprovider/live.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,7 @@ func (rp *LiveRepoProvider) getEntry(url git_url.GitUrl, allowCreate bool, lockR
return e, nil
}

func (rp *LiveRepoProvider) GetRepoInfo(url git_url.GitUrl) (RepoInfo, error) {
e, err := rp.getEntry(url, true, true, true)
if err != nil {
return RepoInfo{}, err
}

func (e *entry) getRepoInfo() (RepoInfo, error) {
remoteRefs, err := e.mr.RemoteRefHashesMap()
if err != nil {
return RepoInfo{}, err
Expand All @@ -127,20 +122,37 @@ func (rp *LiveRepoProvider) GetRepoInfo(url git_url.GitUrl) (RepoInfo, error) {
}

info := RepoInfo{
Url: url,
Url: e.mr.Url(),
RemoteRefs: remoteRefs,
DefaultRef: defaultRef,
}

return info, nil
}

func (rp *LiveRepoProvider) GetRepoInfo(url git_url.GitUrl) (RepoInfo, error) {
e, err := rp.getEntry(url, true, true, true)
if err != nil {
return RepoInfo{}, err
}

return e.getRepoInfo()
}

func (rp *LiveRepoProvider) GetClonedDir(url git_url.GitUrl, ref string) (string, git.CheckoutInfo, error) {
e, err := rp.getEntry(url, true, true, true)
if err != nil {
return "", git.CheckoutInfo{}, err
}

if ref == "" {
ref, err = e.mr.DefaultRef()
if err != nil {
return "", git.CheckoutInfo{}, err
}
ref = path.Base(ref)
}

e.updateMutex.Lock()
defer e.updateMutex.Unlock()

Expand Down

0 comments on commit 8e181c3

Please sign in to comment.