Filter out output organization instead of filtering based on mirror status

This commit is contained in:
2026-07-07 18:08:47 -04:00
parent 6db5922be8
commit 113705f892
+6 -4
View File
@@ -25,7 +25,9 @@ const hashName = ".gvv-hash"
type giteaRespT struct {
Data []struct {
MirrorInterval string `json:"mirror_interval"`
Owner struct {
Organization string `json:"username"`
} `json:"owner"`
Language string `json:"language"`
MasterURL string `json:"original_url"`
Name string `json:"name"`
@@ -40,7 +42,7 @@ func main() {
}
baseURL := os.Args[1]
apiURL := baseURL + "/api/v1/repos/search?sort=updated&order=asc&limit=999"
organization := os.Args[2]
outputOrganization := os.Args[2]
fmt.Print("Input token: ")
token := back.ReadFromStdin()
if len(token) == 0 {
@@ -79,7 +81,7 @@ func main() {
os.Mkdir(workingDir, 0755)
repoLoop:
for _, repoResp := range giteaResp.Data {
if repoResp.Language == "Go" && repoResp.MirrorInterval != "" {
if repoResp.Owner.Organization != outputOrganization && repoResp.Language == "Go" {
currentRepoDir := workingDir + "/" + repoResp.Name + "-ggv"
//// skip if local copy is already up-to-date
targetRepoDir := finishedDir + "/" + repoResp.Name + "-ggv"
@@ -143,7 +145,7 @@ repoLoop:
//// set origin
if _, err = newRepo.CreateRemote(&config.RemoteConfig{
Name: "origin",
URLs: []string{baseURL + "/" + organization + "/" + repoResp.Name + "-ggv.git"},
URLs: []string{baseURL + "/" + outputOrganization + "/" + repoResp.Name + "-ggv.git"},
}); err != nil {
other.PrintError("Failed to set origin for "+currentRepoDir+": "+err.Error(), 13)
}