diff --git a/client.go b/client.go index fc88ea0..7ceaa64 100644 --- a/client.go +++ b/client.go @@ -73,7 +73,7 @@ func getToken(service string) (string, error) { } func newClient(service string, gitHostURL string) interface{} { - gitHostURLParsed := parseGitHostURL(gitHostURL) + gitHostURLParsed := parseGitHostURL(gitHostURL, service) switch service { case "github": @@ -90,7 +90,10 @@ func newClient(service string, gitHostURL string) interface{} { } // parseGitHostURL parses the git host URL if provided -func parseGitHostURL(gitHostURL string) *url.URL { +// TODO: there is a chance, this parsing breaks more than +// one git service +// https://github.com/amitsaha/gitbackup/issues/195 +func parseGitHostURL(gitHostURL string, service string) *url.URL { if len(gitHostURL) == 0 { return nil } @@ -99,6 +102,11 @@ func parseGitHostURL(gitHostURL string) *url.URL { if err != nil { log.Fatalf("Invalid git host URL: %s", gitHostURL) } + + // temp fix for https://github.com/amitsaha/gitbackup/issues/193 + if service == "forgejo" { + return gitHostURLParsed + } api, _ := url.Parse("api/v4/") return gitHostURLParsed.ResolveReference(api) } @@ -197,6 +205,7 @@ func newForgejoClient(gitHostURLParsed *url.URL) *forgejo.Client { url = gitHostURLParsed.String() } + log.Println("Creating forgejo client", url) client, err := forgejo.NewClient(url, forgejo.SetToken(forgejoToken), forgejo.SetForgejoVersion("")) if err != nil { log.Fatalf("Error creating forgejo client: %v", err) diff --git a/git_repository_clone.go b/git_repository_clone.go index 8af2912..f34d7c1 100644 --- a/git_repository_clone.go +++ b/git_repository_clone.go @@ -7,7 +7,7 @@ import ( ) // handleGitRepositoryClone clones or updates all repositories for the configured service -func handleGitRepositoryClone(client interface{}, c *appConfig) error { +func handleGitRepositoryClone(client any, c *appConfig) error { // Used for waiting for all the goroutines to finish before exiting var wg sync.WaitGroup