git

package
v2.0.0-snapshot...-58e3a78 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AddSubCmd = models.Command{
	Name:      "add",
	ShortHelp: "Add the git remote for the given code service to the local git repo",
	LongHelp: "`git-remote add` adds the proper git remote to a local git repository with the given remote name and service. " +
		"Here is a sample command\n\n" +
		"```\ncatalyze -E \"<your_env_alias>\" git-remote add code-1 -r catalyze-code-1\n```",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(subCmd *cli.Cmd) {
			serviceName := subCmd.StringArg("SERVICE_NAME", "", "The name of the service to add a git remote for")
			remote := subCmd.StringOpt("r remote", "catalyze", "The name of the git remote to be added")
			subCmd.Action = func() {
				if _, err := auth.New(settings, prompts.New()).Signin(); err != nil {
					logrus.Fatal(err.Error())
				}
				if err := config.CheckRequiredAssociation(true, true, settings); err != nil {
					logrus.Fatal(err.Error())
				}
				err := CmdAdd(*serviceName, *remote, New(), services.New(settings))
				if err != nil {
					logrus.Fatalln(err.Error())
				}
			}
			subCmd.Spec = "SERVICE_NAME [-r]"
		}
	},
}
View Source
var Cmd = models.Command{
	Name:      "git-remote",
	ShortHelp: "Manage git remotes to Catalyze code services",
	LongHelp: "The `git-remote` command allows you to interact with code service remote git URLs. " +
		"The git-remote command can not be run directly but has sub commands.",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(cmd *cli.Cmd) {
			cmd.CommandLong(AddSubCmd.Name, AddSubCmd.ShortHelp, AddSubCmd.LongHelp, AddSubCmd.CmdFunc(settings))
			cmd.CommandLong(ShowSubCmd.Name, ShowSubCmd.ShortHelp, ShowSubCmd.LongHelp, ShowSubCmd.CmdFunc(settings))
		}
	},
}

Cmd is the contract between the user and the CLI. This specifies the command name, arguments, and required/optional arguments and flags for the command.

View Source
var ShowSubCmd = models.Command{
	Name:      "show",
	ShortHelp: "Print out the git remote for a given code service",
	LongHelp: "`git-remote show` prints out the git remote URL for the given service. " +
		"This can be used to do a manual push or use the git remote for another purpose such as a CI integration. " +
		"Here is a sample command\n\n" +
		"```\ncatalyze -E \"<your_env_alias>\" git-remote show code-1\n```",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(subCmd *cli.Cmd) {
			serviceName := subCmd.StringArg("SERVICE_NAME", "", "The name of the service to add a git remote for")
			subCmd.Action = func() {
				if _, err := auth.New(settings, prompts.New()).Signin(); err != nil {
					logrus.Fatal(err.Error())
				}
				if err := config.CheckRequiredAssociation(true, true, settings); err != nil {
					logrus.Fatal(err.Error())
				}
				err := CmdShow(*serviceName, services.New(settings))
				if err != nil {
					logrus.Fatalln(err.Error())
				}
			}
			subCmd.Spec = "SERVICE_NAME"
		}
	},
}

Functions

func CmdAdd

func CmdAdd(svcName, remote string, ig IGit, is services.IServices) error

func CmdShow

func CmdShow(svcName string, is services.IServices) error

Types

type IGit

type IGit interface {
	Add(remote, gitURL string) error
	Exists() bool
	List() ([]string, error)
	Rm(remote string) error
}

IGit is an interface through which you can perform git operations

func New

func New() IGit

New creates a new instance of IGit

type SGit

type SGit struct{}

SGit is an implementor of IGit

func (*SGit) Add

func (g *SGit) Add(remote, gitURL string) error

Add a git remote to a git repo in the current working directory. If the current working directory is not yet a git repo, this command will fail.

func (*SGit) Exists

func (g *SGit) Exists() bool

Exists tells you whether or not a git repo exists in the current working directory.

func (*SGit) List

func (g *SGit) List() ([]string, error)

List returns a list of all git removes in the current working directory.

func (*SGit) Rm

func (g *SGit) Rm(remote string) error

Rm removes an existing git remote from a git repo in the current working directory.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL