feat: removed unused code
This commit is contained in:
parent
61e22e2c08
commit
8247c4c7e4
2 changed files with 10 additions and 16 deletions
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func fetchRepositoriesGitlab() ([]Repository, error) {
|
func fetchRepositoriesGitlab() ([]Repository) {
|
||||||
|
|
||||||
// default options
|
// default options
|
||||||
membership := "membership=true"
|
membership := "membership=true"
|
||||||
|
|
@ -29,7 +29,7 @@ func fetchRepositoriesGitlab() ([]Repository, error) {
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("creating request: %v", err)
|
fmt.Errorf("creating request: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
req.Header.Set("PRIVATE-TOKEN", gitlabToken)
|
req.Header.Set("PRIVATE-TOKEN", gitlabToken)
|
||||||
|
|
@ -37,22 +37,22 @@ func fetchRepositoriesGitlab() ([]Repository, error) {
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("making request: %v", err)
|
fmt.Errorf("making request: %v", err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return nil, fmt.Errorf("API request failed with status: %d", resp.StatusCode)
|
fmt.Errorf("API request failed with status: %d", resp.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
var repositories []Repository
|
var repositories []Repository
|
||||||
if err := json.NewDecoder(resp.Body).Decode(&repositories); err != nil {
|
if err := json.NewDecoder(resp.Body).Decode(&repositories); err != nil {
|
||||||
return nil, fmt.Errorf("decoding response: %v", err)
|
fmt.Errorf("decoding response: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(repositories) < 1 {
|
if len(repositories) < 1 {
|
||||||
return nil, fmt.Errorf("no repositories found")
|
fmt.Errorf("no repositories found")
|
||||||
}
|
}
|
||||||
|
|
||||||
return repositories, nil
|
return repositories
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,18 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
|
||||||
"log"
|
|
||||||
)
|
|
||||||
|
|
||||||
// userdata
|
// userdata
|
||||||
var repoDestinationPre string
|
var repoDestinationPre string
|
||||||
var includeArchived string
|
var includeArchived string
|
||||||
var gitlabToken string
|
var gitlabToken string
|
||||||
var gitlabHost string
|
var gitlabHost string
|
||||||
|
|
||||||
// count 🧛
|
// keep count 🧛
|
||||||
var clonedCount int
|
var clonedCount int
|
||||||
var errorCount int
|
var errorCount int
|
||||||
var pulledCount int
|
var pulledCount int
|
||||||
var pullErrorMsg []string
|
var pullErrorMsg []string
|
||||||
|
|
||||||
|
// repository data
|
||||||
type Repository struct {
|
type Repository struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
PathWithNamespace string `json:"path_with_namespace"`
|
PathWithNamespace string `json:"path_with_namespace"`
|
||||||
|
|
@ -30,10 +27,7 @@ func main() {
|
||||||
verifyGitAvailable()
|
verifyGitAvailable()
|
||||||
|
|
||||||
// fetch repository information from gitlab
|
// fetch repository information from gitlab
|
||||||
repositories, err := fetchRepositoriesGitlab()
|
repositories := fetchRepositoriesGitlab()
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Error fetching repositories: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// manage found repositories
|
// manage found repositories
|
||||||
progressBar(repositories)
|
progressBar(repositories)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue