Exemple #1
0
func (r *Runner) Execute() ExecError {
	args := NewArgs(os.Args[1:])
	args.ProgramPath = os.Args[0]
	forceFail := false

	if args.Command == "" {
		args.Command = "help"
		forceFail = true
	}

	git.GlobalFlags = args.GlobalFlags // preserve git global flags
	if !isBuiltInHubCommand(args.Command) {
		expandAlias(args)
	}

	cmd := r.Lookup(args.Command)
	if cmd != nil && cmd.Runnable() {
		execErr := r.Call(cmd, args)
		if execErr.ExitCode == 0 && forceFail {
			execErr = newExecError(fmt.Errorf(""))
		}
		return execErr
	}

	gitArgs := []string{args.Command}
	gitArgs = append(gitArgs, args.Params...)

	err := git.Run(gitArgs...)
	return newExecError(err)
}
Exemple #2
0
func (r *Runner) Execute() ExecError {
	args := NewArgs(os.Args[1:])

	if args.Command == "" {
		printUsage()
		return newExecError(nil)
	}

	updater := NewUpdater()
	err := updater.PromptForUpdate()
	utils.Check(err)

	git.GlobalFlags = args.GlobalFlags // preserve git global flags
	expandAlias(args)

	cmd := r.Lookup(args.Command)
	if cmd != nil && cmd.Runnable() {
		return r.Call(cmd, args)
	}

	err = git.Run(args.Command, args.Params...)
	return newExecError(err)
}