diff --git a/internal/synrk/synrk.go b/internal/synrk/synrk.go index deaef89..8e4338b 100644 --- a/internal/synrk/synrk.go +++ b/internal/synrk/synrk.go @@ -70,14 +70,13 @@ func (c *concrete) GetForks(ctx context.Context) ([]*RepositoryWithDetails, erro func (c *concrete) SyncBranchWithUpstreamRepo(repo *RepositoryWithDetails) error { request := &github.RepoMergeUpstreamRequest{Branch: &repo.DefaultBranch} - res, resp, err := c.client.Repositories.MergeUpstream(context.Background(), repo.Owner, repo.Name, request) - - if resp.StatusCode == http.StatusConflict { - return fmt.Errorf("couldn't merge with upstream %s branch due to conflict", res.GetBaseBranch()) - } + _, resp, err := c.client.Repositories.MergeUpstream(context.Background(), repo.Owner, repo.Name, request) if err != nil { - return fmt.Errorf("couldn't merge with upstream %s branch: %w", res.GetBaseBranch(), err) + if resp != nil && resp.StatusCode == http.StatusConflict { + return fmt.Errorf("couldn't merge with upstream %s branch due to conflict", repo.DefaultBranch) + } + return fmt.Errorf("couldn't merge with upstream %s branch: %w", repo.DefaultBranch, err) } return nil diff --git a/internal/ui/item.go b/internal/ui/item.go index ea6f77e..37391b8 100644 --- a/internal/ui/item.go +++ b/internal/ui/item.go @@ -28,7 +28,7 @@ func (i item) Title() string { return iconSynced + " " + titleStr } - if !i.synced && i.repo.Error != nil { + if !i.synced && (i.repo.Error != nil || i.errMsg != "") { return errorStyle.Render(iconSyncFailed + " " + titleStr) } @@ -50,6 +50,11 @@ func (i item) Description() string { return errorStyle.Copy().PaddingLeft(2).Render(msg) } + if i.errMsg != "" { + msg := base + " fail to sync with " + upstream + fmt.Sprintf(" (%s)", i.errMsg) + return errorStyle.Copy().PaddingLeft(2).Render(msg) + } + if !i.synced { upstream = fmt.Sprintf("%s:%s", repo.Parent, repo.DefaultBranch) msg := fmt.Sprintf("%s is %d commit%s behind %s", base, repo.BehindBy, mayBePlural(repo.BehindBy), upstream)