Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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
}
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion git_repository_clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading