@@ -192,7 +192,7 @@ func (c *Client) AddRepoToTeam(ctx context.Context, org, team, repo, perm string
192192 return ErrRepoNotFound
193193 }
194194
195- return fmt .Errorf ("add repo to team: %w" , err )
195+ return fmt .Errorf ("%s/%s: add repo to team: %w" , org , repo , err )
196196 }
197197
198198 if relationExists {
@@ -225,7 +225,7 @@ func (c *Client) RemoveRepoFromTeam(ctx context.Context, org, team, repo string)
225225 return ErrRepoNotFound
226226 }
227227
228- return fmt .Errorf ("remove repo from team: %w" , err )
228+ return fmt .Errorf ("%s/%s: remove repo from team: %w" , org , repo , err )
229229 }
230230
231231 cs .PrintPost ()
@@ -336,7 +336,7 @@ func (c *Client) CreateRepo(ctx context.Context, org string, repo *github.Reposi
336336 return fmt .Errorf ("github: hit rate limit" )
337337 }
338338
339- return fmt .Errorf ("create repo: %w" , err )
339+ return fmt .Errorf ("%s/%s: create repo: %w" , org , repo , err )
340340 }
341341
342342 cs .PrintPost ()
@@ -389,7 +389,11 @@ func (c *Client) UpdateRepo(ctx context.Context, org, repo string, edits *github
389389 return ErrRepoNotFound
390390 }
391391
392- return fmt .Errorf ("update repo: %w" , err )
392+ if resp .StatusCode == http .StatusForbidden && strings .Contains (err .Error (), "was archived so is read-only" ) {
393+ return fmt .Errorf ("%s/%s: update repo: repo is archived" , org , repo )
394+ }
395+
396+ return fmt .Errorf ("%s/%s: update repo: %w" , org , repo , err )
393397 }
394398
395399 cs .PrintPost ()
@@ -416,7 +420,7 @@ func (c *Client) SetRepoTopics(ctx context.Context, org, repo string, topics []s
416420 return ErrRepoNotFound
417421 }
418422
419- return fmt .Errorf ("set repo topics: %w" , err )
423+ return fmt .Errorf ("%s/%s: set repo topics: %w" , org , repo , err )
420424 }
421425
422426 cs .PrintPost ()
@@ -489,7 +493,11 @@ func (c *Client) ProtectBranch(ctx context.Context, org, repo, branch string, pr
489493 return ErrBranchProtectionNotFound
490494 }
491495
492- return fmt .Errorf ("protect branch: %w" , err )
496+ if resp .StatusCode == http .StatusForbidden && strings .Contains (err .Error (), "was archived so is read-only" ) {
497+ return fmt .Errorf ("%s/%s: protect branch: repo is archived" , org , repo )
498+ }
499+
500+ return fmt .Errorf ("%s/%s: protect branch: %w" , org , repo , err )
493501 }
494502
495503 cs .PrintPost ()
@@ -536,7 +544,11 @@ func (c *Client) SetRequireSignedCommits(ctx context.Context, org, repo, branch
536544 return ErrBranchProtectionNotFound
537545 }
538546
539- return fmt .Errorf ("protect branch: set signature required: %w" , err )
547+ if resp .StatusCode == http .StatusForbidden && strings .Contains (err .Error (), "was archived so is read-only" ) {
548+ return fmt .Errorf ("%s/%s: protect branch: set signature required: repo is archived" , org , repo )
549+ }
550+
551+ return fmt .Errorf ("%s/%s: protect branch: set signature required: %w" , org , repo , err )
540552 }
541553
542554 cs .PrintPost ()
0 commit comments