updated comments in structs, updated error handler
This commit is contained in:
parent
2984d3da01
commit
ca671e035f
11
functions.go
11
functions.go
@ -167,10 +167,8 @@ func MigrateReposToGogs(config *Config, repolist []GitHubRepo) {
|
||||
|
||||
client.Timeout = config.globalconfig.RequestTimeout
|
||||
|
||||
resp, err := client.Do(req)
|
||||
HandleError(err)
|
||||
|
||||
fmt.Println(resp.StatusCode)
|
||||
_, err = client.Do(req)
|
||||
HandleFatalError(err)
|
||||
} else {
|
||||
fmt.Println(fmt.Sprintf("Not migrating, %s exists in gogs", elem.Name))
|
||||
}
|
||||
@ -178,11 +176,10 @@ func MigrateReposToGogs(config *Config, repolist []GitHubRepo) {
|
||||
}
|
||||
|
||||
// HandleError handles errors to return err
|
||||
func HandleError(err error) error {
|
||||
func HandleError(err error) {
|
||||
if err != nil {
|
||||
return err
|
||||
log.Println(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// HandleFatalError fatal errors
|
||||
|
10
types.go
10
types.go
@ -14,7 +14,7 @@ type GogsOrg struct {
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
// GogsMigrateRepo ...
|
||||
// GogsMigrateRepo defines the repo to migrate
|
||||
type GogsMigrateRepo struct {
|
||||
Name string
|
||||
CloneURL string
|
||||
@ -22,20 +22,20 @@ type GogsMigrateRepo struct {
|
||||
Mirror bool
|
||||
}
|
||||
|
||||
// Config ...
|
||||
// Config merge all config elements
|
||||
type Config struct {
|
||||
globalconfig GlobalConfig
|
||||
gogsconfig GogsConfig
|
||||
githubconfig GitHubConfig
|
||||
}
|
||||
|
||||
// GlobalConfig ...
|
||||
// GlobalConfig is the global config of github-to-gogs
|
||||
type GlobalConfig struct {
|
||||
RequestTimeout time.Duration
|
||||
UserAgent string
|
||||
}
|
||||
|
||||
// GitHubConfig ...
|
||||
// GitHubConfig is the GitHub config
|
||||
type GitHubConfig struct {
|
||||
StarsPages string
|
||||
MaxPagesNumber int
|
||||
@ -44,7 +44,7 @@ type GitHubConfig struct {
|
||||
ContentType string
|
||||
}
|
||||
|
||||
// GogsConfig ...
|
||||
// GogsConfig is the Gogs config
|
||||
type GogsConfig struct {
|
||||
UID int
|
||||
Username string
|
||||
|
Loading…
Reference in New Issue
Block a user