add branch arg
All checks were successful
Release / release (push) Successful in 1m34s

This commit is contained in:
cdryzun 2023-12-23 21:28:11 +08:00
parent a9456bd63a
commit 60d4290703
2 changed files with 9 additions and 2 deletions

View File

@ -4,3 +4,6 @@
# Release Notes
v0.1.0
- Add gitlab to get the content of a specified file in the repository and save it locally.
v0.1.1
- Add branch argument to specify the branch of the repository.

View File

@ -14,6 +14,7 @@ var (
url string
getFilePath string
outputfilePath string
branch string
)
var rawCmd = &cobra.Command{
@ -28,7 +29,7 @@ var rawCmd = &cobra.Command{
}
// 获取仓库中指定文件的内容
file, _, err := client.RepositoryFiles.GetRawFile(pid, getFilePath, nil)
file, _, err := client.RepositoryFiles.GetRawFile(pid, getFilePath, &gitlab.GetRawFileOptions{Ref: gitlab.String(branch)})
if err != nil {
log.Fatal(err)
}
@ -47,9 +48,12 @@ func init() {
rawCmd.Flags().StringVarP(&url, "url", "u", "", "The url of gitlab.")
rawCmd.Flags().StringVarP(&getFilePath, "getfile-path", "g", "", "The getfile path.")
rawCmd.Flags().StringVarP(&outputfilePath, "outputfile-path", "o", "", "The outputfile path.")
rawCmd.Flags().StringVarP(&branch, "branch", "b", "main", "The project branch of gitlab.")
rawCmd.MarkFlagRequired("project-id")
rawCmd.MarkFlagRequired("token")
rawCmd.MarkFlagRequired("url")
rawCmd.MarkFlagRequired("outputfile-path")
rawCmd.MarkFlagRequired("getfile-path")
rawCmd.MarkFlagRequired("branch")
}