How to ensure that a repository has been synced to the Github servers?
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
Línea de trabajo
Comience con las llamadas RepositoriesService.Create, Get y Edit mostradas en la reproducción y, a continuación, compare sus respuestas de API con el estado del repositorio en github.com. Determine si el cliente expone una comprobación fiable de disponibilidad para habilitar Advanced Security y Secret Scanning, y documente el comportamiento admitido o la limitación cuando el repositorio todavía se está propagando.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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)
- Lenguaje dominante
- Go
- Estrellas
- 11.3k
- Forks
- 2.5k
- Merge medio
- 1 d 16 h
- PR fusionados (30 d)
- 51
Preparar el entorno
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de google/go-github
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Add actions policies endpoints Abierto
google/go-github#4583 · 2 comentarios · 1 reacción · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
google/go-github#4526 · 1 comentario · 1 reacción · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
google/go-github#4524 · 1 reacción · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de google/go-github
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
Remove obsolete ipAllocationPolicy field from containernodepool-subnetworkref test dependency Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
GoogleCloudPlatform/k8s-config-connector#13462 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
coder/coder#29955 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
microsoft/TypeScript#64453 ·
Los mantenedores suelen responder en 1 día
-
OpenAI-compatible endpoint: response ids have only 999 possible values (chatcmpl-rand.Intn(999)) Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día