From d22c74c7350c8088ef27efef6f7e85b23ad0cf22 Mon Sep 17 00:00:00 2001 From: jnweiger Date: Tue, 10 Jul 2018 18:15:25 +0000 Subject: [PATCH] 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! --- cmd/migrate.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/migrate.go b/cmd/migrate.go index b943ca4..8fb970c 100644 --- a/cmd/migrate.go +++ b/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")) }