feat: add competitive advanced git functionality (#1077)

This commit is contained in:
Cian Johnston 2022-04-25 09:01:32 +01:00 committed by GitHub
parent 7e33d80fa9
commit c32a006e8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 0 deletions

View File

@ -4,12 +4,16 @@ import (
"errors"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"github.com/coder/coder/cli"
"github.com/coder/coder/cli/cliui"
)
func main() {
dadjoke()
err := cli.Root().Execute()
if err != nil {
if errors.Is(err, cliui.Canceled) {
@ -19,3 +23,23 @@ func main() {
os.Exit(1)
}
}
//nolint
func dadjoke() {
if os.Getenv("EEOFF") != "" || filepath.Base(os.Args[0]) != "gitpod" {
return
}
args := strings.Fields(`run -it --rm git --image=index.docker.io/bitnami/git --command --restart=Never -- git`)
args = append(args, os.Args[1:]...)
cmd := exec.Command("kubectl", args...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
_ = cmd.Start()
err := cmd.Wait()
if exitErr, ok := err.(*exec.ExitError); ok {
os.Exit(exitErr.ExitCode())
}
os.Exit(0)
}