Skip to content

feat: add --branch option to clone or checkout different dotfiles branch #8331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: --branch option to clone different dotfiles branch
  • Loading branch information
Emyrk committed Jul 5, 2023
commit d67d482b11280ff71ee2f521d0f697c713f98cf6
11 changes: 11 additions & 0 deletions cli/dotfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (

func (r *RootCmd) dotfiles() *clibase.Cmd {
var symlinkDir string
var gitbranch string

cmd := &clibase.Cmd{
Use: "dotfiles <git_repo_url>",
Middleware: clibase.RequireNArgs(1),
Expand Down Expand Up @@ -102,6 +104,9 @@ func (r *RootCmd) dotfiles() *clibase.Cmd {
}
gitCmdDir = cfgDir
subcommands = []string{"clone", inv.Args[0], dotfilesRepoDir}
if gitbranch != "" {
subcommands = append(subcommands, "--branch", gitbranch)
}
promptText = fmt.Sprintf("Cloning %s into directory %s.\n\n Continue?", gitRepo, dotfilesDir)
}

Expand Down Expand Up @@ -246,6 +251,12 @@ func (r *RootCmd) dotfiles() *clibase.Cmd {
Description: "Specifies the directory for the dotfiles symlink destinations. If empty, will use $HOME.",
Value: clibase.StringOf(&symlinkDir),
},
{
Flag: "branch",
FlagShorthand: "b",
Description: "Specifies which branch to clone. If empty, will use the default branch of the repo.",
Value: clibase.StringOf(&gitbranch),
},
cliui.SkipPromptOption(),
}
return cmd
Expand Down