allow explicit GITHUB_USER and GITHUB_PASS

when migrating a private repo from an organization, the following error occurs:

    gitea-github-migrator_linux_amd64 migrate --gh-token $GITHUB_TOKEN --token $GITEA_TOKEN --owner 1 --gh-repo $ORGA/$REPO --url $GITEA_SERVER

    panic: error while migrating repo[ORGA/REPO]: Clone: exit status 128 - fatal: could not read Username for 'https://github.com': No such device or address

This patch fices htat by allowing to infuse the correct credentials like this:

    env GITHUB_PASS=$GITHUB_TOKEN GITHUB_USER=jnweiger ~/go/bin/gitea-github-migrator migrate --gh-token $GITHUB_TOKEN --token $GITEA_TOKEN --owner 1 --gh-repo $ORGA/$REPO --url $GITEA_SERVER

Not the nicest implementation, but this gets me going. Thank you for a great tool!
master
jnweiger 6 years ago
parent afd81459b9
commit d22c74c735
  1. 7
      cmd/migrate.go

@ -1,6 +1,7 @@
package cmd
import (
"os"
"context"
"fmt"
"strings"
@ -54,6 +55,12 @@ func runMigrate(ctx *cli.Context) error {
username := strings.Split(ctx.String("gh-repo"), "/")[0]
repo := strings.Split(ctx.String("gh-repo"), "/")[1]
if u := os.Getenv("GITHUB_USER"); u != "" {
m.AuthUsername = u
}
if p := os.Getenv("GITHUB_PASS"); p != "" {
m.AuthPassword = p
}
return migrate(c, gc, m, username, repo, ctx.Bool("only-repo"))
}

Loading…
Cancel
Save