Skip to content

Commit

Permalink
Completely drop hub support
Browse files Browse the repository at this point in the history
We have partially supported the `hub` tool instead of directly call Git when
handling github repositories. However, many new features in lab don't recall
any equivalent in hub, and, at the same time, GitHub has created another
cli, deprecating `hub` itself. With that, we should also drop it and forget
any compatibility between them.

Signed-off-by: Bruno Meneguele <[email protected]>
  • Loading branch information
bmeneg committed Mar 2, 2021
1 parent f60cf61 commit d3da0ad
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 58 deletions.
16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<p align="center"><img src="https://user-images.githubusercontent.com/1964720/42740177-6478d834-8858-11e8-9667-97f193ecb404.gif" align="center"></p>

Lab wraps Git or [Hub](https://github.com/github/hub), making it simple to clone, fork, and interact with repositories on GitLab, including seamless workflows for creating merge requests, issues and snippets.
Lab wraps Git, making it simple to clone, fork, and interact with repositories on GitLab, including seamless workflows for creating merge requests, issues and snippets.

```
$ lab clone gitlab-com/infrastructure
Expand All @@ -11,16 +11,6 @@ $ lab clone gitlab-com/infrastructure
$ git clone [email protected]:gitlab-com/infrastructure
```

## hub + <img src="https://user-images.githubusercontent.com/3167497/34473826-40b4987c-ef2c-11e7-90b9-5ff322c4966f.png" width="30" height="30"> = hublab??

lab will look for hub and uses that as your git binary when available so you don't have to give up hub to use lab
```
$ lab version
git version 2.11.0
hub version 2.3.0-pre9
lab version 0.20.0
```

# Inspiration

The [hub](https://github.com/github/hub) tool made my life significantly easier and still does! lab is heavily inspired by hub and attempts to provide a similar feel.
Expand All @@ -29,7 +19,7 @@ The [hub](https://github.com/github/hub) tool made my life significantly easier

Dependencies

* `git` or `hub`
* `git`

### Homebrew
```
Expand Down Expand Up @@ -147,7 +137,7 @@ source <(lab completion zsh)

# Aliasing

Like hub, lab feels best when aliased as `git`, however it's perfectly reasonable to use as a standalone tool. In your `.bashrc` or `.bash_profile`:
`lab` feels best when aliased as `git`, however it's perfectly reasonable to use as a standalone tool. In your `.bashrc` or `.bash_profile`:

```
alias git=lab
Expand Down
13 changes: 0 additions & 13 deletions cmd/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,6 @@ func forkFromOrigin(project string) {
log.Fatal("remote: upstream already exists")
}

remoteURL, err := gitconfig.Local("remote.origin.url")
if err != nil {
log.Fatal(err)
}
if git.IsHub && strings.Contains(remoteURL, "github.com") {
git := git.New("fork")
git.Run()
if err != nil {
log.Fatal(err)
}
return
}

forkRemoteURL, err := lab.Fork(project, forkOpts, useHTTP, waitFork)
if err != nil {
if err.Error() == "not finished" {
Expand Down
17 changes: 1 addition & 16 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,8 @@ func helpFunc(cmd *cobra.Command, args []string) {
}
return
}
formatChar := "\n"
if git.IsHub {
formatChar = ""
}

formatChar := "\n"
git := git.New()
git.Stdout = nil
git.Stderr = nil
Expand Down Expand Up @@ -182,7 +179,6 @@ func Execute() {
if err != nil || cmd.Use == "clone" {
// Determine if any undefined flags were passed to "clone"
// TODO: Evaluate and support some of these flags
// NOTE: `hub help -a` wraps the `git help -a` output
if (cmd.Use == "clone" && len(os.Args) > 2) || os.Args[1] == "help" {
// ParseFlags will err in these cases
err = cmd.ParseFlags(os.Args[1:])
Expand All @@ -195,17 +191,6 @@ func Execute() {
}
}

// Lab passthrough for these commands can cause confusion. See #163
if os.Args[1] == "create" {
log.Fatalf("Please call `hub create` directly for github, the lab equivalent is `lab project create`")
}
if os.Args[1] == "browse" {
log.Fatalf("Please call `hub browse` directly for github, the lab equivalent is `lab <object> browse`")
}
if os.Args[1] == "alias" {
log.Fatalf("Please call `hub alias` directly for github, there is no lab equivalent`")
}

// Passthrough to git for any unrecognized commands
err = git.New(os.Args[1:]...).Run()
if exiterr, ok := err.(*exec.ExitError); ok {
Expand Down
19 changes: 3 additions & 16 deletions internal/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,11 @@ import (
gitconfig "github.com/tcnksm/go-gitconfig"
)

// IsHub is true when using "hub" as the git binary
var IsHub bool

func init() {
_, err := exec.LookPath("hub")
if err == nil {
IsHub = true
}
}

// New looks up the hub or git binary and returns a cmd which outputs to stdout
// New looks up the git binary and returns a cmd which outputs to stdout
func New(args ...string) *exec.Cmd {
gitPath, err := exec.LookPath("hub")
gitPath, err := exec.LookPath("git")
if err != nil {
gitPath, err = exec.LookPath("git")
if err != nil {
log.Fatal(err)
}
log.Fatal(err)
}

cmd := exec.Command(gitPath, args...)
Expand Down

0 comments on commit d3da0ad

Please sign in to comment.