How to ensure that a repository has been synced to the Github servers?
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 25/100
Rechercherichtung
Beginnen Sie mit den in der Reproduktion gezeigten Aufrufen von RepositoriesService.Create, Get und Edit und vergleichen Sie anschließend deren API-Antworten mit dem Repository-Status auf github.com. Ermitteln Sie, ob der Client eine zuverlässige Bereitschaftsprüfung für die Aktivierung von Advanced Security und Secret Scanning bereitstellt, und dokumentieren Sie das unterstützte Verhalten oder die Einschränkung, wenn das Repository noch propagiert wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
The documentation for RepositoriesService.Create states that
Also note that this method will return the response without actually
waiting for GitHub to finish creating the repository and letting the
changes propagate throughout its servers. You may set up a loop with
exponential back-off to verify repository's creation.
However, doing so does not seem to be sufficient to ensure that a new repository has been synced.
I'm trying to create a new repository and enable Github Advanced Security features after it. The Update request returns a 200 and the result also indicates a success (the updated fields contain the value "enabled" which is what I wanted to achieve). When validating the result on github.com the features are disabled.
When I tried to sleep for a couple of seconds after creating and before updating the repo, the result is also visible on github.com.
Here is my code to reproduce the issue:
package main
import (
"context"
"fmt"
"time"
"github.com/google/go-github/v67/github"
log "github.com/sirupsen/logrus"
)
func main() {
org := "some-org"
name := "some-repo"
token := "some-token"
client := github.NewClient(nil).WithAuthToken(token)
_, _, err := client.Repositories.Create(context.Background(), org, &github.Repository{
Name: github.String(name),
AutoInit: github.Bool(true),
Visibility: github.String("internal"),
DefaultBranch: github.String("main"),
})
if err != nil {
log.WithError(err).Fatal("unable to create repository")
}
maxRetries := 5
for i := 0; i < maxRetries; i++ {
_, _, err := client.Repositories.Get(context.Background(), org, name)
if err == nil {
break
}
if i == maxRetries-1 {
log.Fatal("unable to verify repository creation")
}
time.Sleep(time.Duration(i*2) * time.Second)
}
// time.Sleep(5 * time.Second)
repo := github.Repository{
SecurityAndAnalysis: &github.SecurityAndAnalysis{
AdvancedSecurity: &github.AdvancedSecurity{
Status: github.String("enabled"),
},
SecretScanning: &github.SecretScanning{
Status: github.String("enabled"),
},
},
}
updatedRepo, _, err := client.Repositories.Edit(context.Background(), org, name, &repo)
if err != nil {
log.Fatal("unable to enable Advanced Security")
}
fmt.Printf("Advanced Security: %s\n", *updatedRepo.SecurityAndAnalysis.AdvancedSecurity.Status)
fmt.Printf("Secret Scanning: %s\n", *updatedRepo.SecurityAndAnalysis.SecretScanning.Status)
}
No matter if I sleep the 5 seconds or not, both run print
Advanced Security: enabled
Secret Scanning: enabled
github.com without sleeping
github.com with sleeping
Any idea how I can make sure that the repository is ready to enable Advanced Security features? (I'm not sure if other updates are affected as well)
- Vorherrschende Sprache
- Go
- Sterne
- 11.3k
- Forks
- 2.6k
- Ø Merge
- 2 T. 19 Std.
- Gemergte PRs (30 T.)
- 33
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus google/go-github
-
Error() methods modify the request URL of the response they wrapEvtl. vergeben @AdamMagued hat das vor 1 Tag übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 30/100
Maintainer antworten meist innerhalb von 1 Tag
-
Add support for Copilot coding agent permissions APIEvtl. vergeben @ninadsutrave hat das vor 1 Tag übernommen. Offen
google/go-github#4650 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 5/100
google/go-github#4636 · 2 Kommentare · 3 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
-
http.Client.Timeout is ignored by redirect-aware requestsEvtl. vergeben @sb123sb123 hat das vor 30 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
Add Copilot content exclusion set/get enterprise and org set endpointsEvtl. vergeben @Tens1des hat das vor 44 Tagen übernommen. Offen
google/go-github#4526 · 1 Kommentar · 1 Reaktion · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in google/go-github
Ähnliche Issues
-
bug triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
mvanhorn/cli-printing-press#5146 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
AvengeMedia/DankMaterialShell#3853 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 60/100
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag