Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions internal/synrk/synrk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion internal/ui/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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)
Expand Down
Loading