Skip to content

Commit 393e75a

Browse files
committed
Merge remote-tracking branch 'origin' into pr-merge
2 parents 5c6dbb4 + 705360d commit 393e75a

File tree

556 files changed

+1529
-301940
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

556 files changed

+1529
-301940
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,39 @@ jobs:
88
strategy:
99
fail-fast: false
1010
matrix:
11-
go: [ '1.9', '1.10', '1.11', '1.12', '1.13' ]
11+
go: ["1.11", "1.12", "1.13", "1.14"]
1212

1313
steps:
14-
- uses: actions/checkout@v1
15-
16-
- name: Set up Ruby
17-
uses: actions/setup-ruby@v1
18-
with:
19-
ruby-version: 2.6.x
20-
21-
- name: Cache gems
22-
uses: actions/cache@v1
23-
with:
24-
path: vendor/bundle
25-
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
26-
restore-keys: |
27-
${{ runner.os }}-gem-
28-
29-
- name: Bundle install
30-
run: |
31-
bundle install --path vendor/bundle
32-
bundle binstub cucumber --path bin
33-
34-
- name: Set up Go
35-
uses: actions/setup-go@v1
36-
with:
37-
go-version: ${{ matrix.go }}
38-
39-
# - name: Install system packages
40-
# if: runner.os == 'Linux'
41-
# run: sudo apt-get install -y zsh fish
42-
43-
- name: Run tests
44-
shell: bash
45-
run: |
46-
export GOPATH="$HOME"/go
47-
mkdir -p "$GOPATH"/src/github.com/github
48-
ln -svf "$PWD" "$GOPATH"/src/github.com/github/hub
49-
cd "$GOPATH"/src/github.com/github/hub
50-
make test-all
51-
env:
52-
CI: true
14+
- uses: actions/checkout@v1
15+
16+
- name: Set up Ruby
17+
uses: actions/setup-ruby@v1
18+
with:
19+
ruby-version: 2.6.x
20+
21+
- name: Cache gems
22+
uses: actions/cache@v1
23+
with:
24+
path: vendor/bundle
25+
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
26+
restore-keys: |
27+
${{ runner.os }}-gem-
28+
29+
- name: Bundle install
30+
run: |
31+
bundle install --path vendor/bundle
32+
bundle binstub cucumber --path bin
33+
34+
- name: Set up Go
35+
uses: actions/setup-go@v1
36+
with:
37+
go-version: ${{ matrix.go }}
38+
39+
# - name: Install system packages
40+
# if: runner.os == 'Linux'
41+
# run: sudo apt-get install -y zsh fish
42+
43+
- name: Run tests
44+
run: make test-all
45+
env:
46+
CI: true

.github/workflows/release.yml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
name: Release
22
on:
33
push:
4-
tags: 'v*'
4+
tags: "v*"
55

66
jobs:
77
release:
88
name: Publish release
99
runs-on: ubuntu-latest
10-
steps:
11-
- uses: actions/checkout@v1
12-
- name: Set up Go
13-
uses: actions/setup-go@v1
14-
with:
15-
go-version: "1.13"
16-
- name: Run tests
17-
run: script/publish-release
18-
env:
19-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2010

21-
jobs:
22-
homebrew:
23-
name: Bump Homebrew formula
24-
runs-on: ubuntu-latest
2511
steps:
26-
- uses: mislav/[email protected]
12+
- uses: actions/checkout@v2
13+
14+
- name: Set up Go
15+
uses: actions/setup-go@v1
16+
with:
17+
go-version: "1.13"
18+
19+
- name: Publish release script
20+
run: script/publish-release
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- uses: mislav/bump-homebrew-formula-action@v1
2725
if: "!contains(github.ref, '-')" # skip prereleases
2826
with:
2927
formula-name: hub
3028
env:
3129
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ tags
1414
/site
1515
/hub
1616
.vscode
17+
.DS_Store

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN apt-get purge --auto-remove -y curl \
66
&& rm -rf /var/lib/apt/lists/*
77

88
RUN groupadd -r app && useradd -r -g app -G sudo app \
9-
&& mkdir -p /home/app && chown -R app:app /home/app
9+
&& mkdir -p /home/app && chown -R app:app /home/app
1010
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
1111

1212
USER app
@@ -20,5 +20,4 @@ COPY Gemfile Gemfile.lock ./
2020
RUN bundle install
2121

2222
ENV LANG C.UTF-8
23-
ENV GOFLAGS -mod=vendor
2423
ENV USER app

Makefile

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
SOURCES = $(shell script/build files)
1+
SOURCES = $(shell go list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}}\
2+
{{end}}' ./...)
23
SOURCE_DATE_EPOCH ?= $(shell date +%s)
34
BUILD_DATE = $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" '+%d %b %Y' 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" '+%d %b %Y')
45
HUB_VERSION = $(shell bin/hub version | tail -1)
5-
FLAGS_ALL = $(shell go version | grep -q 'go1.[89]' || echo 'all=')
6-
export GOFLAGS := $(shell go version | grep -q 'go1.1[^0]' && echo '-mod=vendor')
7-
export LDFLAGS := -extldflags '$(LDFLAGS)'
8-
export GCFLAGS := $(FLAGS_ALL)-trimpath '$(PWD)'
9-
export ASMFLAGS := $(FLAGS_ALL)-trimpath '$(PWD)'
106

11-
ifneq ($(GOFLAGS),)
12-
export GO111MODULE=on
13-
unexport GOPATH
14-
endif
7+
export GO111MODULE=on
8+
unexport GOPATH
9+
10+
export LDFLAGS := -extldflags '$(LDFLAGS)'
11+
export GCFLAGS := all=-trimpath '$(PWD)'
12+
export ASMFLAGS := all=-trimpath '$(PWD)'
1513

16-
MIN_COVERAGE = 89.4
14+
MIN_COVERAGE = 90.2
1715

1816
HELP_CMD = \
1917
share/man/man1/hub-alias.1 \
@@ -53,7 +51,7 @@ bin/hub: $(SOURCES)
5351
script/build -o $@
5452

5553
bin/md2roff: $(SOURCES)
56-
go build -o $@ github.com/github/hub/md2roff-bin
54+
go build -o $@ github.com/github/hub/v2/md2roff-bin
5755

5856
test:
5957
go test ./...

README.md

Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
hub is a command line tool that wraps `git` in order to extend it with extra
22
features and commands that make working with GitHub easier.
33

4+
For an official, potentially more user-friendly command-line interface to GitHub,
5+
see [cli.github.com](https://cli.github.com) and
6+
[this comparison](https://github.com/cli/cli/blob/trunk/docs/gh-vs-hub.md).
7+
48
This repository and its issue tracker is **not for reporting problems with
59
GitHub.com** web interface. If you have a problem with GitHub itself, please
610
[contact Support](https://github.com/contact).
@@ -10,19 +14,23 @@ Usage
1014

1115
``` sh
1216
$ hub clone rtomayko/tilt
13-
14-
# expands to:
1517
#=> git clone git://github.com/rtomayko/tilt.git
18+
19+
# if you prefer HTTPS to git/SSH protocols:
20+
$ git config --global hub.protocol https
21+
$ hub clone rtomayko/tilt
22+
#=> git clone https://github.com/rtomayko/tilt.git
1623
```
1724

18-
hub can be safely [aliased](#aliasing) as `git` so you can type `$ git
19-
<command>` in the shell and get all the usual `hub` features.
25+
See [usage examples](https://hub.github.com/#developer) or the [full reference
26+
documentation](https://hub.github.com/hub.1.html) to see all available commands
27+
and flags.
2028

21-
See [Usage documentation](https://hub.github.com/hub.1.html) for the list of all
22-
commands and their arguments.
29+
hub can also be used to make shell scripts that [directly interact with the
30+
GitHub API](https://hub.github.com/#scripting).
2331

24-
hub can also be used to make shell scripts that [manually interface with the
25-
GitHub API](https://hub.github.com/hub-api.1.html).
32+
hub can be safely [aliased](#aliasing) as `git`, so you can type `$ git
33+
<command>` in the shell and have it expanded with `hub` features.
2634

2735
Installation
2836
------------
@@ -39,20 +47,51 @@ Fedora Linux | [DNF](https://fedoraproject.org/wiki/DNF) | `sudo dnf install hub
3947
Arch Linux | [pacman](https://wiki.archlinux.org/index.php/pacman) | `sudo pacman -S hub`
4048
FreeBSD | [pkg(8)](http://man.freebsd.org/pkg/8) | `pkg install hub`
4149
Debian | [apt(8)](https://manpages.debian.org/buster/apt/apt.8.en.html) | `sudo apt install hub`
42-
Ubuntu | [Snap](https://snapcraft.io) | `snap install hub --classic`
50+
Ubuntu | [Snap](https://snapcraft.io) | [We do not recommend installing the snap anymore.](https://github.com/github/hub/issues?q=is%3Aissue+snap)
51+
openSUSE | [Zypper](https://en.opensuse.org/SDB:Zypper_manual) | `sudo zypper install hub`
52+
Void Linux | [xbps](https://github.com/void-linux/xbps) | `sudo xbps-install -S hub`
53+
Gentoo | [Portage](https://wiki.gentoo.org/wiki/Portage) | `sudo emerge dev-vcs/hub`
54+
_any_ | [conda](https://docs.conda.io/en/latest/) | `conda install -c conda-forge hub`
55+
56+
57+
Packages other than Homebrew are community-maintained (thank you!) and they
58+
are not guaranteed to match the [latest hub release][latest]. Check `hub
59+
version` after installing a community package.
4360

4461
#### Standalone
4562

46-
`hub` can be easily installed as an executable. Download the latest
47-
[compiled binaries](https://github.com/github/hub/releases) and put it anywhere
48-
in your executable path.
63+
`hub` can be easily installed as an executable. Download the [latest
64+
binary][latest] for your system and put it anywhere in your executable path.
65+
66+
#### GitHub Actions
67+
68+
hub is ready to be used in your [GitHub Actions][] workflows:
69+
```yaml
70+
steps:
71+
- uses: actions/checkout@v2
72+
73+
- name: List open pull requests
74+
run: hub pr list
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
```
78+
79+
Note that the default `secrets.GITHUB_TOKEN` will only work for API operations
80+
scoped to the repository that runs this workflow. If you need to interact with other
81+
repositories, [generate a Personal Access Token][pat] with at least the `repo` scope
82+
and add it to your [repository secrets][].
83+
84+
85+
[github actions]: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
86+
[pat]: https://github.com/settings/tokens
87+
[repository secrets]: https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets
4988

5089
#### Source
5190

5291
Prerequisites for building from source are:
5392

5493
* `make`
55-
* [Go 1.9+](https://golang.org/doc/install)
94+
* [Go 1.11+](https://golang.org/doc/install)
5695

5796
Clone this repository and run `make install`:
5897

@@ -67,11 +106,6 @@ cd hub
67106
make install prefix=/usr/local
68107
```
69108

70-
This assumes support for [Go 1.11+
71-
modules](https://github.com/golang/go/wiki/Modules). If you are building on an
72-
older version of Go, you will need to clone the repository into
73-
`$GOPATH/src/github.com/github/hub`.
74-
75109
Aliasing
76110
--------
77111

@@ -113,18 +147,15 @@ New-Item -Type file -Force $PROFILE
113147

114148
### Shell tab-completion
115149

116-
hub repository contains tab-completion scripts for bash, zsh and fish.
150+
hub repository contains [tab-completion scripts](./etc) for bash, zsh and fish.
117151
These scripts complement existing completion scripts that ship with git.
118152

119-
[Installation instructions](etc)
120-
121-
* [hub bash completion](https://github.com/github/hub/blob/master/etc/hub.bash_completion.sh)
122-
* [hub zsh completion](https://github.com/github/hub/blob/master/etc/hub.zsh_completion)
123-
* [hub fish completion](https://github.com/github/hub/blob/master/etc/hub.fish_completion)
124-
125153
Meta
126154
----
127155

128-
* Home: <https://github.com/github/hub>
129156
* Bugs: <https://github.com/github/hub/issues>
130157
* Authors: <https://github.com/github/hub/contributors>
158+
* Our [Code of Conduct](https://github.com/github/hub/blob/master/CODE_OF_CONDUCT.md)
159+
160+
161+
[latest]: https://github.com/github/hub/releases/latest

cmd/cmd.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import (
88
"strings"
99
"syscall"
1010

11-
"github.com/github/hub/ui"
11+
"github.com/github/hub/v2/ui"
1212
)
1313

14+
// Cmd is a project-wide struct that represents a command to be run in the console.
1415
type Cmd struct {
1516
Name string
1617
Args []string
@@ -20,9 +21,20 @@ type Cmd struct {
2021
}
2122

2223
func (cmd Cmd) String() string {
23-
return fmt.Sprintf("%s %s", cmd.Name, strings.Join(cmd.Args, " "))
24+
args := make([]string, len(cmd.Args))
25+
for i, a := range cmd.Args {
26+
if strings.ContainsRune(a, '"') {
27+
args[i] = fmt.Sprintf(`'%s'`, a)
28+
} else if a == "" || strings.ContainsRune(a, '\'') || strings.ContainsRune(a, ' ') {
29+
args[i] = fmt.Sprintf(`"%s"`, a)
30+
} else {
31+
args[i] = a
32+
}
33+
}
34+
return fmt.Sprintf("%s %s", cmd.Name, strings.Join(args, " "))
2435
}
2536

37+
// WithArg returns the current argument
2638
func (cmd *Cmd) WithArg(arg string) *Cmd {
2739
cmd.Args = append(cmd.Args, arg)
2840

@@ -64,9 +76,8 @@ func (cmd *Cmd) Success() bool {
6476
func (cmd *Cmd) Run() error {
6577
if isWindows() {
6678
return cmd.Spawn()
67-
} else {
68-
return cmd.Exec()
6979
}
80+
return cmd.Exec()
7081
}
7182

7283
func isWindows() bool {
@@ -137,7 +148,7 @@ func NewWithArray(cmd []string) *Cmd {
137148

138149
func verboseLog(cmd *Cmd) {
139150
if os.Getenv("HUB_VERBOSE") != "" {
140-
msg := fmt.Sprintf("$ %s %s", cmd.Name, strings.Join(cmd.Args, " "))
151+
msg := fmt.Sprintf("$ %s", cmd.String())
141152
if ui.IsTerminal(os.Stderr) {
142153
msg = fmt.Sprintf("\033[35m%s\033[0m", msg)
143154
}

cmd/cmd_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package cmd
33
import (
44
"testing"
55

6-
"github.com/bmizerany/assert"
6+
"github.com/github/hub/v2/internal/assert"
77
)
88

99
func TestNew(t *testing.T) {
@@ -18,3 +18,11 @@ func TestWithArg(t *testing.T) {
1818
assert.Equal(t, "git", execCmd.Name)
1919
assert.Equal(t, 4, len(execCmd.Args))
2020
}
21+
22+
func Test_String(t *testing.T) {
23+
c := Cmd{
24+
Name: "echo",
25+
Args: []string{"hi", "hello world", "don't", `"fake news"`},
26+
}
27+
assert.Equal(t, `echo hi "hello world" "don't" '"fake news"'`, c.String())
28+
}

0 commit comments

Comments
 (0)