Skip to content

Commit

Permalink
added git pull
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Sep 11, 2020
1 parent 6e87403 commit 0bee864
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 54 deletions.
16 changes: 16 additions & 0 deletions completers/git_completer/cmd/action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ func ActionRemotes() carapace.Action {
})
}

func ActionRemoteBranches(remote string) carapace.Action {
return carapace.ActionCallback(func(args []string) carapace.Action {
if branches, err := Branches(RefOption{RemoteBranches: true}); err != nil {
return carapace.ActionMessage(err.Error())
} else {
vals := make([]string, 0)
for _, branch := range branches {
if strings.HasPrefix(branch.Name, remote) {
vals = append(vals, strings.TrimPrefix(branch.Name, remote+"/"), branch.Message)
}
}
return carapace.ActionValuesDescribed(vals...)
}
})
}

type RefOption struct {
LocalBranches bool
RemoteBranches bool
Expand Down
Original file line number Diff line number Diff line change
@@ -1,54 +1,92 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/completers/git_completer/cmd/action"
"github.com/spf13/cobra"
)

var pullCmd = &cobra.Command{
Use: "pull",
Short: "Fetch from and integrate with another repository or a local branch",
Run: func(cmd *cobra.Command, args []string) {
},
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
pullCmd.Flags().BoolP("ipv4", "4", false, "use IPv4 addresses only")
pullCmd.Flags().BoolP("ipv6", "6", false, "use IPv6 addresses only")
pullCmd.Flags().BoolP("append", "a", false, "append to .git/FETCH_HEAD instead of overwriting")
carapace.Gen(pullCmd).Standalone()

pullCmd.Flags().BoolS("n", "n", false, "do not show a diffstat at the end of the merge")
pullCmd.Flags().Bool("all", false, "fetch from all remotes")
pullCmd.Flags().Bool("allow-unrelated-histories", false, "allow merging unrelated histories")
pullCmd.Flags().Bool("autostash", false, "automatically stash/stash pop before and after rebase")
pullCmd.Flags().BoolP("append", "a", false, "append to .git/FETCH_HEAD instead of overwriting")
pullCmd.Flags().Bool("autostash", false, "automatically stash/stash pop before and after")
pullCmd.Flags().String("cleanup", "", "how to strip spaces and #comments from message")
pullCmd.Flags().Bool("commit", false, "perform a commit if the merge succeeds (default)")
pullCmd.Flags().String("deepen", "", "deepen history of shallow clone")
pullCmd.Flags().String("depth", "", "deepen history of shallow clone")
pullCmd.Flags().Bool("dry-run", false, "dry run")
pullCmd.Flags().Bool("edit", false, "edit message before committing")
pullCmd.Flags().Bool("ff", false, "allow fast-forward")
pullCmd.Flags().Bool("ff-only", false, "abort if fast-forward is not possible")
pullCmd.Flags().BoolP("force", "f", false, "force overwrite of local branch")
pullCmd.Flags().StringP("gpg-sign", "S", "", "GPG sign commit")
pullCmd.Flags().BoolP("ipv4", "4", false, "use IPv4 addresses only")
pullCmd.Flags().BoolP("ipv6", "6", false, "use IPv6 addresses only")
pullCmd.Flags().StringP("jobs", "j", "", "number of submodules pulled in parallel")
pullCmd.Flags().BoolP("keep", "k", false, "keep downloaded pack")
pullCmd.Flags().String("log", "", "add (at most <n>) entries from shortlog to merge commit message")
pullCmd.Flags().BoolP("n", "n", false, "do not show a diffstat at the end of the merge")
pullCmd.Flags().BoolP("prune", "p", false, "prune remote-tracking branches no longer on remote")
pullCmd.Flags().String("negotiation-tip", "", "report that we have only objects reachable from this object")
pullCmd.Flags().Bool("progress", false, "force progress reporting")
pullCmd.Flags().BoolP("prune", "p", false, "prune remote-tracking branches no longer on remote")
pullCmd.Flags().BoolP("quiet", "q", false, "be more quiet")
pullCmd.Flags().StringP("rebase", "r", "", "incorporate changes by rebasing rather than merging")
pullCmd.Flags().String("recurse-submodules", "", "control for recursive fetching of submodules")
pullCmd.Flags().String("refmap", "", "specify fetch refmap")
pullCmd.Flags().StringP("rebase", "r", "", "incorporate changes by rebasing rather than merging")
pullCmd.Flags().StringP("server-option", "o", "", "option to transmit")
pullCmd.Flags().Bool("set-upstream", false, "set upstream for git pull/fetch")
pullCmd.Flags().StringP("gpg-sign", "S", "", "GPG sign commit")
pullCmd.Flags().String("shallow-exclude", "", "deepen history of shallow clone, excluding rev")
pullCmd.Flags().String("shallow-since", "", "deepen history of shallow repository based on time")
pullCmd.Flags().Bool("show-forced-updates", false, "check for forced-updates on all updated branches")
pullCmd.Flags().String("signoff", "", "add Signed-off-by:")
pullCmd.Flags().Bool("squash", false, "create a single commit instead of doing a merge")
pullCmd.Flags().BoolP("strategy", "s", false, "<strategy> merge strategy to use")
pullCmd.Flags().Bool("stat", false, "show a diffstat at the end of the merge")
pullCmd.Flags().StringP("strategy", "s", "", "merge strategy to use")
pullCmd.Flags().StringP("strategy-option", "X", "", "option for selected merge strategy")
pullCmd.Flags().BoolP("tags", "t", false, "fetch all tags and associated objects")
pullCmd.Flags().Bool("unshallow", false, "convert to a complete repository")
pullCmd.Flags().Bool("update-shallow", false, "accept refs that update .git/shallow")
pullCmd.Flags().String("upload-pack", "", "path to upload pack on remote end")
pullCmd.Flags().Bool("verify-signatures", false, "verify that the named commit has a valid GPG signature")
pullCmd.Flags().BoolP("verbose", "v", false, "be more verbose")
pullCmd.Flags().BoolP("strategy-option", "X", false, "<option=value> option for selected merge strategy")
pullCmd.Flags().Bool("verify-signatures", false, "verify that the named commit has a valid GPG signature")
rootCmd.AddCommand(pullCmd)

carapace.Gen(pullCmd).FlagCompletion(carapace.ActionMap{
"cleanup": carapace.ActionValuesDescribed(
"default", "act as 'strip' if the message is to be edited and as 'whitespace' otherwise",
"scissors", "same as whitespace but cut from scissor line",
"strip", "remove both whitespace and commentary lines",
"verbatim", "don't change the commit message at all",
"whitespace", "remove leading and trailing whitespace lines",
),
"rebase": carapace.ActionValuesDescribed(
"false", "merge after fetching",
"interactive", "allow list of commits to be edited",
"merges", "try to rebase merges instead of skipping them",
"preserve", "rebase and preserve merges",
"true", "rebase after fetching",
),
"recurse-submodules": carapace.ActionValuesDescribed(
"no", "disable recursion",
"on-demand", "only when submodule reference in superproject is updated",
"yes", "always recurse",
),
"strategy": carapace.ActionValues("octopus", "ours", "recursive", "resolve", "subtree"),
})

carapace.Gen(pullCmd).PositionalCompletion(
action.ActionRemotes(),
carapace.ActionCallback(func(args []string) carapace.Action {
return action.ActionRemoteBranches(args[0])
}),
)
}
41 changes: 0 additions & 41 deletions completers/git_completer/cmd/push_generated.go

This file was deleted.

0 comments on commit 0bee864

Please sign in to comment.