diff --git a/README.md b/README.md index e75372d..1f6868e 100644 --- a/README.md +++ b/README.md @@ -556,7 +556,6 @@ COPYRIGHT: OPTIONS: --base-url value 实例地址,例如:https://gitlab.xuxiaowei.com.cn/api/v4 (default: "https://gitlab.com/api/v4") [%CI_API_V4_URL%] --token value your_access_token - --username value 用户名 --owned 当前用户明确拥有的项目。 (default: false) --export-folder value 导出文件夹 --skip-project-path value [ --skip-project-path value ] 跳过项目路径 diff --git a/constant/common.go b/constant/common.go index 00f0502..94d6a1c 100644 --- a/constant/common.go +++ b/constant/common.go @@ -1,7 +1,6 @@ package constant const ( - Username = "username" Token = "token" BaseUrl = "base-url" BaseUrlDefault = "https://gitlab.com/api/v4" diff --git a/flag/flag.go b/flag/flag.go index 76d1636..a92519e 100644 --- a/flag/flag.go +++ b/flag/flag.go @@ -49,14 +49,6 @@ func BaseUrl() cli.Flag { } } -func Username(required bool) cli.Flag { - return &cli.StringFlag{ - Name: constant.Username, - Usage: "用户名", - Required: required, - } -} - func Token(required bool) cli.Flag { return &cli.StringFlag{ Name: constant.Token, diff --git a/mix/export_all.go b/mix/export_all.go index a3768e5..83ad976 100644 --- a/mix/export_all.go +++ b/mix/export_all.go @@ -23,13 +23,12 @@ func ExportAll() *cli.Command { "已包含:\n" + "1. git 仓库\n" + "2. wiki 仓库", - Flags: append(flag.CommonTokenRequired(), flag.Username(true), flag.Owned(true), + Flags: append(flag.CommonTokenRequired(), flag.Owned(true), flag.ExportFolder(true), flag.SkipProjectPath(), flag.SkipProjectWikiPath()), Action: func(context *cli.Context) error { var baseUrl = context.String(constant.BaseUrl) var token = context.String(constant.Token) - var username = context.String(constant.Username) var owned = context.Bool(constant.Owned) var exportFolder = context.String(constant.ExportFolder) var skipProjectPaths = context.StringSlice(constant.SkipProjectPath) @@ -62,12 +61,12 @@ func ExportAll() *cli.Command { for index, project := range projectList { log.Printf("Project Index: %d, WebURL: %s", index, project.WebURL) - err = Repository(exportFolder, host, username, token, project, skipProjectPaths) + err = Repository(exportFolder, host, token, project, skipProjectPaths) if err != nil { return err } - err = Wiki(exportFolder, host, username, token, project, skipProjectWikiPaths) + err = Wiki(exportFolder, host, token, project, skipProjectWikiPaths) if err != nil { return err } @@ -80,7 +79,7 @@ func ExportAll() *cli.Command { } } -func Repository(exportFolder string, host string, username string, token string, project *gitlab.Project, skipProjectPaths []string) error { +func Repository(exportFolder string, host string, token string, project *gitlab.Project, skipProjectPaths []string) error { c := contains(skipProjectPaths, project.PathWithNamespace) if c { @@ -100,7 +99,7 @@ func Repository(exportFolder string, host string, username string, token string, return err } - userinfo := url.UserPassword(username, token) + userinfo := url.UserPassword("", token) repoUrl.User = userinfo cmd := exec.Command("git", "clone", repoUrl.String(), gitPath) @@ -120,7 +119,7 @@ func Repository(exportFolder string, host string, username string, token string, return nil } -func Wiki(exportFolder string, host string, username string, token string, project *gitlab.Project, skipProjectWikiPaths []string) error { +func Wiki(exportFolder string, host string, token string, project *gitlab.Project, skipProjectWikiPaths []string) error { c := contains(skipProjectWikiPaths, project.PathWithNamespace) if c { @@ -146,7 +145,7 @@ func Wiki(exportFolder string, host string, username string, token string, proje return err } - userinfo := url.UserPassword(username, token) + userinfo := url.UserPassword("", token) repoUrl.User = userinfo cmd := exec.Command("git", "clone", repoUrl.String(), wikiPath) diff --git a/mix/mix_export.go b/mix/mix_export.go index 0ca8bf8..b48881b 100644 --- a/mix/mix_export.go +++ b/mix/mix_export.go @@ -10,7 +10,7 @@ func Export() *cli.Command { return &cli.Command{ Name: "mix-export", Usage: "导出(混合命令,多接口命令)", - Flags: append(flag.Common(), flag.Username(false), flag.Owned(false), + Flags: append(flag.Common(), flag.Owned(false), flag.ExportFolder(false), flag.SkipProjectPath(), flag.SkipProjectWikiPath()), Subcommands: []*cli.Command{ ExportAll(),