Skip to content

Commit

Permalink
Merge pull request #37 from tomtwinkle/fix/first-fetch-repo
Browse files Browse the repository at this point in the history
fix: first fetch repository
  • Loading branch information
tomtwinkle authored Aug 15, 2023
2 parents 933243b + 3cf2eff commit 7d75962
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions internal/pkg/gh/gh.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ func (prs PullRequests) SHAs() []string {
}

func (g *gh) GetMergedPRs(ctx context.Context, fromBranch, toBranch string) (PullRequests, error) {
if err := g.remote.FetchContext(ctx, &git.FetchOptions{
RemoteName: "origin",
}); err != nil {
if !errors.Is(err, git.NoErrAlreadyUpToDate) {
return nil, fmt.Errorf("git Remote Fetch error: %w", err)
}
}
toHash, err := g.resolveBranch(ctx, toBranch)
if err != nil {
return nil, err
Expand Down Expand Up @@ -178,14 +185,6 @@ func (g *gh) resolveBranch(ctx context.Context, remoteBranch string) (*plumbing.
}

func (g *gh) fetchMergedPRNumsFromGit(ctx context.Context, fromHash, toHash plumbing.Hash) ([]int, error) {
if err := g.remote.FetchContext(ctx, &git.FetchOptions{
RemoteName: "origin",
}); err != nil {
if !errors.Is(err, git.NoErrAlreadyUpToDate) {
return nil, fmt.Errorf("git Remote Fetch error: %w", err)
}
}

fromCommit, err := g.repository.CommitObject(fromHash)
if err != nil {
return nil, fmt.Errorf("github Git GetCommit fromHash error [%s]: %w", fromHash.String(), err)
Expand Down

0 comments on commit 7d75962

Please sign in to comment.