Compare commits
No commits in common. "fd9f898315c90d2658f9ad24511c45ebf99a47dc" and "f335f5805ffd827b6dc2dbc9d4a8797413a739be" have entirely different histories.
fd9f898315
...
f335f5805f
112
DOCS.md
112
DOCS.md
|
@ -6,14 +6,12 @@ git-ea is the base command
|
|||
git-ea
|
||||
├─ backport
|
||||
├─ branch
|
||||
├─ cd
|
||||
├─ cleanup
|
||||
├─ frontport
|
||||
├─ ide
|
||||
├─ init
|
||||
├─ post
|
||||
├─ pr
|
||||
└─ tag
|
||||
└─ pr
|
||||
```
|
||||
|
||||
|
||||
|
@ -33,6 +31,25 @@ git-ea <cmd>
|
|||
**--version,-v**: Print git-ea version
|
||||
|
||||
|
||||
-----
|
||||
|
||||
## cleanup
|
||||
|
||||
cleanup removes named branches, or interactive if no arguments
|
||||
|
||||
|
||||
```
|
||||
[--help]
|
||||
```
|
||||
**Usage**:
|
||||
|
||||
```
|
||||
cleanup [branches...]
|
||||
```
|
||||
|
||||
**--help**: Show help
|
||||
|
||||
|
||||
-----
|
||||
|
||||
## backport
|
||||
|
@ -44,7 +61,6 @@ backport cherry-picks a commit and applies it to a clean branch based on `releas
|
|||
[--from,-f]=[value]
|
||||
[--help]
|
||||
[--list,-l]
|
||||
[--push,-p]
|
||||
[--to,-t]=[value]
|
||||
```
|
||||
**Usage**:
|
||||
|
@ -62,9 +78,6 @@ backport --from [release=main] --to [release=latest]
|
|||
**--list,-l**: Open repository to see needed backports
|
||||
|
||||
|
||||
**--push,-p**: Push immediately
|
||||
|
||||
|
||||
**--to,-t**="": Release to backport to (ex: `17`, default: `latest`)
|
||||
|
||||
|
||||
|
@ -80,7 +93,7 @@ branch creates a new branch called `name` based on `base`
|
|||
[--help]
|
||||
[--ide,-i]
|
||||
[--list,-l]
|
||||
[--no-fetch,-n]
|
||||
[--no-fetch,-nf]
|
||||
```
|
||||
**Usage**:
|
||||
|
||||
|
@ -100,57 +113,7 @@ branch --base [ref=main] <name>
|
|||
**--list,-l**: List branches available
|
||||
|
||||
|
||||
**--no-fetch,-n**: Skip fetching
|
||||
|
||||
|
||||
-----
|
||||
|
||||
## cleanup
|
||||
|
||||
cleanup removes named branches, or interactive if no arguments
|
||||
|
||||
|
||||
```
|
||||
[--force,-f]
|
||||
[--help]
|
||||
[--prune,-p]
|
||||
```
|
||||
**Usage**:
|
||||
|
||||
```
|
||||
cleanup [branches...]
|
||||
```
|
||||
|
||||
**--force,-f**: Force cleanup
|
||||
|
||||
|
||||
**--help**: Show help
|
||||
|
||||
|
||||
**--prune,-p**: Prune worktrees
|
||||
|
||||
|
||||
-----
|
||||
|
||||
## cd
|
||||
|
||||
Open a shell in the specified `workspace`
|
||||
|
||||
|
||||
```
|
||||
[--help]
|
||||
[--print,-p]
|
||||
```
|
||||
**Usage**:
|
||||
|
||||
```
|
||||
cd [workspace=base]
|
||||
```
|
||||
|
||||
**--help**: Show help
|
||||
|
||||
|
||||
**--print,-p**: Print workspace dir instead of spawning a shell
|
||||
**--no-fetch,-nf**: Skip fetching
|
||||
|
||||
|
||||
-----
|
||||
|
@ -163,7 +126,6 @@ frontport cherry-picks a commit and applies it to a clean branch based on `relea
|
|||
```
|
||||
[--from,-f]=[value]
|
||||
[--help]
|
||||
[--push,-p]
|
||||
[--to,-t]=[value]
|
||||
```
|
||||
**Usage**:
|
||||
|
@ -178,9 +140,6 @@ frontport --from [release=latest] --to [release=main]
|
|||
**--help**: Show help
|
||||
|
||||
|
||||
**--push,-p**: Push immediately
|
||||
|
||||
|
||||
**--to,-t**="": Release to frontport to (ex: `main`, default: `main`)
|
||||
|
||||
|
||||
|
@ -192,7 +151,6 @@ ide starts an IDE for `branch`
|
|||
|
||||
|
||||
```
|
||||
[--gui,-g]
|
||||
[--help]
|
||||
```
|
||||
**Usage**:
|
||||
|
@ -201,9 +159,6 @@ ide starts an IDE for `branch`
|
|||
ide <branch>
|
||||
```
|
||||
|
||||
**--gui,-g**: Prefer GUI editor
|
||||
|
||||
|
||||
**--help**: Show help
|
||||
|
||||
|
||||
|
@ -286,26 +241,3 @@ pr <index>
|
|||
|
||||
-----
|
||||
|
||||
## tag
|
||||
|
||||
tag makes a signed tag for `branch`
|
||||
|
||||
|
||||
```
|
||||
[--help]
|
||||
[--push,-p]
|
||||
```
|
||||
**Usage**:
|
||||
|
||||
```
|
||||
tag <branch>
|
||||
```
|
||||
|
||||
**--help**: Show help
|
||||
|
||||
|
||||
**--push,-p**: Push immediately
|
||||
|
||||
|
||||
-----
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
func (h *Handler) Branch() *ffcli.Command {
|
||||
fs := flag.NewFlagSet("branch", flag.ContinueOnError)
|
||||
noFetchFlag := fs.Bool("no-fetch", false, "Skip fetching")
|
||||
fs.BoolVar(noFetchFlag, "n", *noFetchFlag, "--no-fetch")
|
||||
fs.BoolVar(noFetchFlag, "nf", *noFetchFlag, "--no-fetch")
|
||||
baseFlag := fs.String("base", "main", "Ref to base from")
|
||||
fs.StringVar(baseFlag, "b", *baseFlag, "--base")
|
||||
listFlag := fs.Bool("list", false, "List branches available")
|
||||
|
|
59
cmd/cd.go
59
cmd/cd.go
|
@ -1,59 +0,0 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
|
||||
"go.jolheiser.com/git-ea/config"
|
||||
|
||||
"github.com/peterbourgon/ff/v3/ffcli"
|
||||
)
|
||||
|
||||
func (h *Handler) CD() *ffcli.Command {
|
||||
fs := flag.NewFlagSet("cd", flag.ContinueOnError)
|
||||
printFlag := fs.Bool("print", false, "Print workspace dir instead of spawning a shell")
|
||||
fs.BoolVar(printFlag, "p", *printFlag, "--print")
|
||||
return &ffcli.Command{
|
||||
Name: "cd",
|
||||
FlagSet: fs,
|
||||
ShortUsage: "cd [workspace=base]",
|
||||
ShortHelp: "Open a shell in the specified `workspace`",
|
||||
Exec: func(ctx context.Context, _ []string) error {
|
||||
dir := h.Config.Workspace()
|
||||
if fs.NArg() > 0 {
|
||||
dir = h.Config.WorkspaceBranch(fs.Arg(0))
|
||||
}
|
||||
|
||||
if *printFlag {
|
||||
fmt.Println(dir)
|
||||
return nil
|
||||
}
|
||||
|
||||
command, args := cd(h.Config)
|
||||
cmd := exec.CommandContext(ctx, command, args...)
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Dir = dir
|
||||
return cmd.Run()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func cd(cfg *config.Config) (string, []string) {
|
||||
if cfg.CD.Command != "" {
|
||||
return cfg.CD.Command, cfg.CD.Args
|
||||
}
|
||||
var shell string
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
shell = "powershell.exe"
|
||||
case "linux":
|
||||
shell = "/bin/bash"
|
||||
}
|
||||
return shell, nil
|
||||
}
|
14
cmd/cmd.go
14
cmd/cmd.go
|
@ -45,10 +45,9 @@ func New() (*ffcli.Command, error) {
|
|||
ShortUsage: "git-ea <cmd>",
|
||||
ShortHelp: "git-ea is the base command",
|
||||
Subcommands: []*ffcli.Command{
|
||||
handler.Cleanup(),
|
||||
handler.Backport(),
|
||||
handler.Branch(),
|
||||
handler.Cleanup(),
|
||||
handler.CD(),
|
||||
handler.Frontport(),
|
||||
handler.IDE(),
|
||||
handler.Init(),
|
||||
|
@ -63,7 +62,16 @@ func New() (*ffcli.Command, error) {
|
|||
return nil
|
||||
}
|
||||
|
||||
fmt.Println(ffcli.DefaultUsageFunc(c))
|
||||
dir := cfg.Base
|
||||
if fs.NArg() > 0 {
|
||||
if strings.EqualFold(fs.Arg(0), "help") {
|
||||
fmt.Println(ffcli.DefaultUsageFunc(c))
|
||||
return nil
|
||||
}
|
||||
dir = cfg.WorkspaceBranch(fs.Arg(0))
|
||||
}
|
||||
|
||||
fmt.Println(dir)
|
||||
return nil
|
||||
}
|
||||
return c, nil
|
||||
|
|
22
cmd/ide.go
22
cmd/ide.go
|
@ -12,8 +12,6 @@ import (
|
|||
|
||||
func (h *Handler) IDE() *ffcli.Command {
|
||||
fs := flag.NewFlagSet("ide", flag.ContinueOnError)
|
||||
guiFlag := fs.Bool("gui", false, "Prefer GUI editor")
|
||||
fs.BoolVar(guiFlag, "g", *guiFlag, "--gui")
|
||||
return &ffcli.Command{
|
||||
Name: "ide",
|
||||
FlagSet: fs,
|
||||
|
@ -41,7 +39,7 @@ func (h *Handler) IDE() *ffcli.Command {
|
|||
}
|
||||
|
||||
path := h.Config.WorkspaceBranch(branch)
|
||||
cmd := exec.Command(getIDE(*guiFlag), path)
|
||||
cmd := exec.Command(getIDE(), path)
|
||||
cmd.Dir = path
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
|
@ -51,25 +49,13 @@ func (h *Handler) IDE() *ffcli.Command {
|
|||
}
|
||||
}
|
||||
|
||||
func getIDE(preferGUI bool) string {
|
||||
term := []string{
|
||||
func getIDE() string {
|
||||
for _, ide := range []string{
|
||||
"hx",
|
||||
"nvim",
|
||||
}
|
||||
gui := []string{
|
||||
"lapce",
|
||||
"goland",
|
||||
}
|
||||
def := []string{
|
||||
"vi",
|
||||
}
|
||||
|
||||
ides := append(term, gui...)
|
||||
if preferGUI {
|
||||
ides = append(gui, term...)
|
||||
}
|
||||
|
||||
for _, ide := range append(ides, def...) {
|
||||
} {
|
||||
if i, err := exec.LookPath(ide); err == nil {
|
||||
return i
|
||||
}
|
||||
|
|
|
@ -8,14 +8,8 @@ import (
|
|||
"path/filepath"
|
||||
)
|
||||
|
||||
type CD struct {
|
||||
Command string `json:"command"`
|
||||
Args []string `json:"args"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Base string `json:"base"`
|
||||
CD CD `json:"cd"`
|
||||
}
|
||||
|
||||
func (c *Config) Workspace() string {
|
||||
|
@ -46,13 +40,9 @@ func (c *Config) Branches() ([]string, error) {
|
|||
}
|
||||
|
||||
func path() (string, error) {
|
||||
userCfgDir, ok := os.LookupEnv("XDG_CONFIG_HOME")
|
||||
if !ok {
|
||||
var err error
|
||||
userCfgDir, err = os.UserConfigDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
userCfgDir, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
cfgDir := filepath.Join(userCfgDir, "git-ea")
|
||||
return filepath.Join(cfgDir, "config.json"), os.MkdirAll(cfgDir, os.ModePerm)
|
||||
|
@ -73,7 +63,7 @@ func Load() (*Config, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err := fi.WriteString(`{}`); err != nil {
|
||||
if _, err := fi.WriteString("{}"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err := fi.Seek(0, 0); err != nil {
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
def "nu-complete git-ea branches" [] {
|
||||
^git-ea branch -l | lines | each { |line| $line | str trim }
|
||||
}
|
||||
|
||||
# Backport
|
||||
export extern "git ea backport" [
|
||||
--from(-f) # From branch
|
||||
--list(-l) # Open a web browser to view needed backports
|
||||
--push(-p) # Push immediately
|
||||
--to(-t) # To branch
|
||||
]
|
||||
|
||||
# Branch
|
||||
export extern "git ea branch" [
|
||||
name: string # Branch name
|
||||
--base(-b) # Branch base
|
||||
--ide(-i) # Open an IDE for the new branch
|
||||
--list(-l) # List branches
|
||||
--no-fetch(-n) # Skip fetching
|
||||
]
|
||||
|
||||
# CD
|
||||
export extern "git ea cd" [
|
||||
workspace?: string@"nu-complete git-ea branches" # Workspace
|
||||
--print(-p) # Print instead of spawning shell
|
||||
]
|
||||
|
||||
# Cleanup
|
||||
export extern "git ea cleanup" [
|
||||
...branches: string # Branch names
|
||||
--force(-f) # Force cleanup
|
||||
--prune(-p) # Prune worktrees
|
||||
]
|
||||
|
||||
# Frontport
|
||||
export extern "git ea frontport" [
|
||||
--from(-f) # From branch
|
||||
--push(-p) # Push immediately
|
||||
--to(-t) # To branch
|
||||
]
|
||||
|
||||
# IDE
|
||||
export extern "git ea ide" [
|
||||
workspace?: string@"nu-complete git-ea branches" # Workspace
|
||||
--gui(-g) # Prefer GUI
|
||||
]
|
||||
|
||||
# Init
|
||||
export extern "git ea init" []
|
||||
|
||||
# Post
|
||||
export extern "git ea post" [
|
||||
--author(-a) # Author
|
||||
--changelog(-c) # Changelog (no header)
|
||||
--milestone(-m) # Milestone
|
||||
--output(-o) # Output file (default: `content/post/release-of-${milestone}.md`)
|
||||
]
|
||||
|
||||
# PR
|
||||
export extern "git ea pr" [
|
||||
index: int # PR index
|
||||
--ide(-i) # Open IDE for this PR
|
||||
]
|
||||
|
||||
# Tag
|
||||
export extern "git ea tag" [
|
||||
branch?: string # The branch to tag
|
||||
--push(-p) # Push immediately
|
||||
]
|
||||
|
Loading…
Reference in New Issue