staleRepos -> warnings

This commit is contained in:
Kirill Zhuravlev 2023-02-15 18:17:09 +01:00 committed by Avelino
parent c969fe29c4
commit 97074a851b
No known key found for this signature in database
GPG Key ID: B345B4D52E98180A

View File

@ -185,33 +185,33 @@ func getRepoStates(toRun bool, href string, client *http.Client) ([]string, bool
var isRepoAdded bool var isRepoAdded bool
var staleRepos []string var warnings []string
if resp.StatusCode == http.StatusMovedPermanently { if resp.StatusCode == http.StatusMovedPermanently {
staleRepos = append(staleRepos, href+movedPermanently) warnings = append(warnings, href+movedPermanently)
log.Printf("%s returned %d", href, resp.StatusCode) log.Printf("%s returned %d", href, resp.StatusCode)
isRepoAdded = true isRepoAdded = true
} }
if resp.StatusCode == http.StatusFound && !isRepoAdded { if resp.StatusCode == http.StatusFound && !isRepoAdded {
staleRepos = append(staleRepos, href+status302) warnings = append(warnings, href+status302)
log.Printf("%s returned %d", href, resp.StatusCode) log.Printf("%s returned %d", href, resp.StatusCode)
isRepoAdded = true isRepoAdded = true
} }
if resp.StatusCode >= http.StatusBadRequest && !isRepoAdded { if resp.StatusCode >= http.StatusBadRequest && !isRepoAdded {
staleRepos = append(staleRepos, href+deadLinkMessage) warnings = append(warnings, href+deadLinkMessage)
log.Printf("%s might not exist!", href) log.Printf("%s might not exist!", href)
isRepoAdded = true isRepoAdded = true
} }
if repoResp.Archived && !isRepoAdded { if repoResp.Archived && !isRepoAdded {
staleRepos = append(staleRepos, href+archived) warnings = append(warnings, href+archived)
log.Printf("%s is archived!", href) log.Printf("%s is archived!", href)
isRepoAdded = true isRepoAdded = true
} }
// FIXME: expression `(len(staleRepos) > 0) == isRepoAdded` is always true. // FIXME: expression `(len(warnings) > 0) == isRepoAdded` is always true.
return staleRepos, isRepoAdded return warnings, isRepoAdded
} }
func checkRepoCommitActivity(toRun bool, href string, client *http.Client) ([]string, bool) { func checkRepoCommitActivity(toRun bool, href string, client *http.Client) ([]string, bool) {
@ -306,11 +306,11 @@ func TestStaleRepository(t *testing.T) {
} }
// FIXME: this is `or` expression. Probably we need `and`? // FIXME: this is `or` expression. Probably we need `and`?
staleRepos2, isRepoAdded := getRepoStates(true, href, client) warnings, isRepoAdded := getRepoStates(true, href, client)
staleRepos = append(staleRepos, staleRepos2...) staleRepos = append(staleRepos, warnings...)
staleRepos2, isRepoAdded = checkRepoCommitActivity(!isRepoAdded, href, client) warnings, isRepoAdded = checkRepoCommitActivity(!isRepoAdded, href, client)
staleRepos = append(staleRepos, staleRepos2...) staleRepos = append(staleRepos, warnings...)
if isRepoAdded { if isRepoAdded {
ctr++ ctr++