This commit is contained in:
parent
a9456bd63a
commit
60d4290703
@ -4,3 +4,6 @@
|
|||||||
# Release Notes
|
# Release Notes
|
||||||
v0.1.0
|
v0.1.0
|
||||||
- Add gitlab to get the content of a specified file in the repository and save it locally.
|
- 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.
|
@ -14,6 +14,7 @@ var (
|
|||||||
url string
|
url string
|
||||||
getFilePath string
|
getFilePath string
|
||||||
outputfilePath string
|
outputfilePath string
|
||||||
|
branch string
|
||||||
)
|
)
|
||||||
|
|
||||||
var rawCmd = &cobra.Command{
|
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 {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -47,9 +48,12 @@ func init() {
|
|||||||
rawCmd.Flags().StringVarP(&url, "url", "u", "", "The url of gitlab.")
|
rawCmd.Flags().StringVarP(&url, "url", "u", "", "The url of gitlab.")
|
||||||
rawCmd.Flags().StringVarP(&getFilePath, "getfile-path", "g", "", "The getfile path.")
|
rawCmd.Flags().StringVarP(&getFilePath, "getfile-path", "g", "", "The getfile path.")
|
||||||
rawCmd.Flags().StringVarP(&outputfilePath, "outputfile-path", "o", "", "The outputfile 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("project-id")
|
||||||
rawCmd.MarkFlagRequired("token")
|
rawCmd.MarkFlagRequired("token")
|
||||||
rawCmd.MarkFlagRequired("url")
|
rawCmd.MarkFlagRequired("url")
|
||||||
rawCmd.MarkFlagRequired("outputfile-path")
|
rawCmd.MarkFlagRequired("outputfile-path")
|
||||||
rawCmd.MarkFlagRequired("getfile-path")
|
rawCmd.MarkFlagRequired("getfile-path")
|
||||||
|
rawCmd.MarkFlagRequired("branch")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user