twig 1.6 → 1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/HISTORY.md +27 -0
- data/README.md +41 -22
- data/bin/twig +12 -4
- data/bin/twig-checkout-child +56 -25
- data/bin/twig-checkout-parent +54 -26
- data/bin/twig-create-branch +40 -15
- data/bin/twig-diff +44 -25
- data/bin/twig-gh-open +43 -17
- data/bin/twig-gh-open-issue +51 -23
- data/bin/twig-gh-update +46 -20
- data/bin/twig-help +49 -5
- data/bin/twig-init +46 -13
- data/bin/twig-init-completion +46 -19
- data/bin/twig-init-completion-bash +50 -25
- data/bin/twig-init-config +77 -0
- data/bin/twig-rebase +85 -33
- data/config/twigconfig +47 -0
- data/lib/twig.rb +16 -10
- data/lib/twig/branch.rb +19 -12
- data/lib/twig/cli.rb +118 -183
- data/lib/twig/cli/help.rb +174 -0
- data/lib/twig/commit_time.rb +69 -14
- data/lib/twig/display.rb +19 -6
- data/lib/twig/github.rb +10 -8
- data/lib/twig/options.rb +22 -14
- data/lib/twig/subcommands.rb +13 -1
- data/lib/twig/system.rb +0 -2
- data/lib/twig/util.rb +0 -2
- data/lib/twig/version.rb +1 -1
- data/spec/spec_helper.rb +4 -3
- data/spec/twig/branch_spec.rb +100 -13
- data/spec/twig/cli/help_spec.rb +187 -0
- data/spec/twig/cli_spec.rb +34 -189
- data/spec/twig/commit_time_spec.rb +185 -16
- data/spec/twig/display_spec.rb +69 -48
- data/spec/twig/github_spec.rb +29 -15
- data/spec/twig/options_spec.rb +42 -13
- data/spec/twig/subcommands_spec.rb +35 -2
- data/spec/twig/system_spec.rb +5 -6
- data/spec/twig/util_spec.rb +20 -20
- data/spec/twig_spec.rb +21 -6
- data/twig.gemspec +14 -16
- metadata +23 -27
data/bin/twig-diff
CHANGED
@@ -1,33 +1,52 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
3
|
+
def help_content
|
4
|
+
<<-HELP
|
5
|
+
|
6
|
+
twig-diff
|
7
|
+
=========
|
8
|
+
|
9
|
+
Shows the diff between a branch and its parent branch (`diff-branch`).
|
10
|
+
|
11
|
+
Synopsis
|
12
|
+
--------
|
13
|
+
|
14
|
+
twig diff [<branch>] [<options>]
|
15
|
+
|
16
|
+
Description
|
17
|
+
-----------
|
18
|
+
|
19
|
+
Shows the diff between the current branch and its `diff-branch` property. All
|
20
|
+
options are passed through to `git-diff`.
|
21
|
+
|
22
|
+
Examples
|
23
|
+
--------
|
24
|
+
|
25
|
+
Show diff stats between the current branch and its `diff-branch`:
|
26
|
+
|
27
|
+
twig diff --stat
|
28
|
+
|
29
|
+
Show the diff between the given branch and its `diff-branch`:
|
30
|
+
|
31
|
+
twig diff my_branch
|
32
|
+
|
33
|
+
Show diff stats between the given branch and its `diff-branch`:
|
34
|
+
|
35
|
+
twig diff my_branch --stat
|
36
|
+
|
37
|
+
Subcommand for Twig: <http://rondevera.github.io/twig/>
|
38
|
+
Author: Ron DeVera <http://rondevera.com>
|
39
|
+
|
40
|
+
HELP
|
41
|
+
end
|
28
42
|
|
29
43
|
args = ARGV.dup
|
30
44
|
|
45
|
+
if args.include?('--help')
|
46
|
+
puts help_content
|
47
|
+
exit
|
48
|
+
end
|
49
|
+
|
31
50
|
branch_given = args.any? && args.first[0, 1] != '-'
|
32
51
|
topic_branch = args.shift.strip if branch_given # Use given branch
|
33
52
|
topic_branch ||= `git rev-parse --abbrev-ref HEAD`.strip # Use current branch
|
data/bin/twig-gh-open
CHANGED
@@ -1,26 +1,52 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
# Synopsis:
|
4
|
-
#
|
5
|
-
# twig gh-open
|
6
|
-
#
|
7
|
-
# Description:
|
8
|
-
#
|
9
|
-
# Opens a browser window for the current GitHub repo.
|
10
|
-
#
|
11
|
-
# To customize the GitHub URI prefix (e.g., for GitHub Enterprise
|
12
|
-
# installations), set GitHub options in `~/.twigconfig`:
|
13
|
-
#
|
14
|
-
# github-uri-prefix: http://example-enterprise.github.com
|
15
|
-
# github-api-uri-prefix: http://example-enterprise.github.com
|
16
|
-
#
|
17
|
-
# Subcommand for Twig: <http://rondevera.github.io/twig/>
|
18
|
-
# Author: Ron DeVera <http://rondevera.com>
|
19
|
-
|
20
3
|
require 'rubygems'
|
21
4
|
require 'twig'
|
22
5
|
require 'launchy'
|
23
6
|
|
7
|
+
def help_content
|
8
|
+
<<-HELP
|
9
|
+
|
10
|
+
twig-gh-open
|
11
|
+
============
|
12
|
+
|
13
|
+
Opens a browser window for the current GitHub repository.
|
14
|
+
|
15
|
+
Synopsis
|
16
|
+
--------
|
17
|
+
|
18
|
+
twig gh-open
|
19
|
+
|
20
|
+
Description
|
21
|
+
-----------
|
22
|
+
|
23
|
+
Opens a browser window for the current GitHub repository.
|
24
|
+
|
25
|
+
To customize the GitHub URI prefix (e.g., for GitHub Enterprise
|
26
|
+
installations), set GitHub options in `~/.twigconfig`:
|
27
|
+
|
28
|
+
github-uri-prefix: http://example-enterprise.github.com
|
29
|
+
github-api-uri-prefix: http://example-enterprise.github.com
|
30
|
+
|
31
|
+
See also
|
32
|
+
--------
|
33
|
+
|
34
|
+
twig-gh-open-issue
|
35
|
+
twig-gh-update
|
36
|
+
|
37
|
+
Subcommand for Twig: <http://rondevera.github.io/twig/>
|
38
|
+
Author: Ron DeVera <http://rondevera.com>
|
39
|
+
|
40
|
+
HELP
|
41
|
+
end
|
42
|
+
|
43
|
+
args = ARGV.dup
|
44
|
+
|
45
|
+
if args.include?('--help')
|
46
|
+
puts help_content
|
47
|
+
exit
|
48
|
+
end
|
49
|
+
|
24
50
|
Twig::GithubRepo.new do |gh_repo|
|
25
51
|
twig = Twig.new(:read_options => true)
|
26
52
|
gh_uri_prefix = twig.options[:github_uri_prefix]
|
data/bin/twig-gh-open-issue
CHANGED
@@ -1,30 +1,57 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
# Synopsis:
|
4
|
-
#
|
5
|
-
# twig gh-open-issue [-b|--branch <branch>]
|
6
|
-
#
|
7
|
-
# Description:
|
8
|
-
#
|
9
|
-
# Opens a browser window the GitHub issue, if any, for the current branch.
|
10
|
-
#
|
11
|
-
# To customize the GitHub URI prefix (e.g., for GitHub Enterprise
|
12
|
-
# installations), set GitHub options in `~/.twigconfig`:
|
13
|
-
#
|
14
|
-
# github-uri-prefix: http://example-enterprise.github.com
|
15
|
-
# github-api-uri-prefix: http://example-enterprise.github.com
|
16
|
-
#
|
17
|
-
# Options:
|
18
|
-
#
|
19
|
-
# `-b` or `--branch`: Opens the GitHub issue, if any, for the given branch.
|
20
|
-
#
|
21
|
-
# Subcommand for Twig: <http://rondevera.github.io/twig/>
|
22
|
-
# Author: Ron DeVera <http://rondevera.com>
|
23
|
-
|
24
3
|
require 'rubygems'
|
25
4
|
require 'twig'
|
26
5
|
require 'launchy'
|
27
6
|
|
7
|
+
def help_content
|
8
|
+
<<-HELP
|
9
|
+
|
10
|
+
twig-gh-open-issue
|
11
|
+
==================
|
12
|
+
|
13
|
+
Opens a browser window for a branch's GitHub issue, if any.
|
14
|
+
|
15
|
+
Synopsis
|
16
|
+
--------
|
17
|
+
|
18
|
+
twig gh-open-issue [-b|--branch <branch>]
|
19
|
+
|
20
|
+
Description
|
21
|
+
-----------
|
22
|
+
|
23
|
+
Opens a browser window for the GitHub issue, if any, for the current branch.
|
24
|
+
|
25
|
+
To customize the GitHub URI prefix (e.g., for GitHub Enterprise
|
26
|
+
installations), set GitHub options in `~/.twigconfig`:
|
27
|
+
|
28
|
+
github-uri-prefix: http://example-enterprise.github.com
|
29
|
+
github-api-uri-prefix: http://example-enterprise.github.com
|
30
|
+
|
31
|
+
Options
|
32
|
+
-------
|
33
|
+
|
34
|
+
`-b` or `--branch`: Opens the GitHub issue, if any, for the given branch.
|
35
|
+
|
36
|
+
See also
|
37
|
+
--------
|
38
|
+
|
39
|
+
twig-gh-open
|
40
|
+
twig-gh-update
|
41
|
+
|
42
|
+
Subcommand for Twig: <http://rondevera.github.io/twig/>
|
43
|
+
Author: Ron DeVera <http://rondevera.com>
|
44
|
+
|
45
|
+
HELP
|
46
|
+
end
|
47
|
+
|
48
|
+
args = ARGV.dup
|
49
|
+
|
50
|
+
if args.include?('--help')
|
51
|
+
puts help_content
|
52
|
+
exit
|
53
|
+
end
|
54
|
+
|
28
55
|
Twig::GithubRepo.new do |gh_repo|
|
29
56
|
twig = Twig.new(:read_options => true)
|
30
57
|
target_branch_name = twig.target_branch_name
|
@@ -35,8 +62,9 @@ Twig::GithubRepo.new do |gh_repo|
|
|
35
62
|
end
|
36
63
|
|
37
64
|
gh_uri_prefix = twig.options[:github_uri_prefix]
|
38
|
-
url =
|
39
|
-
|
65
|
+
url =
|
66
|
+
"#{gh_uri_prefix}/#{gh_repo.username}/#{gh_repo.repository}" \
|
67
|
+
"/issues/#{issue_id}"
|
40
68
|
|
41
69
|
puts "GitHub issue URL: #{url}"
|
42
70
|
Launchy.open(url) rescue nil
|
data/bin/twig-gh-update
CHANGED
@@ -1,28 +1,54 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
# Synopsis:
|
4
|
-
#
|
5
|
-
# twig gh-update
|
6
|
-
#
|
7
|
-
# Description:
|
8
|
-
#
|
9
|
-
# Updates each branch with the latest issue status on GitHub.
|
10
|
-
#
|
11
|
-
# To customize the GitHub URI prefix (e.g., for GitHub Enterprise
|
12
|
-
# installations), set GitHub options in `~/.twigconfig`:
|
13
|
-
#
|
14
|
-
# github-uri-prefix: http://example-enterprise.github.com
|
15
|
-
# github-api-uri-prefix: http://example-enterprise.github.com
|
16
|
-
#
|
17
|
-
# Subcommand for Twig: <http://rondevera.github.io/twig/>
|
18
|
-
# Author: Ron DeVera <http://rondevera.com>
|
19
|
-
|
20
|
-
require File.join(File.dirname(__FILE__), '..', 'lib', 'twig')
|
21
3
|
require 'rubygems'
|
4
|
+
require 'twig'
|
22
5
|
require 'json'
|
23
6
|
require 'net/https'
|
24
7
|
require 'uri'
|
25
8
|
|
9
|
+
def help_content
|
10
|
+
<<-HELP
|
11
|
+
|
12
|
+
twig-gh-update
|
13
|
+
==============
|
14
|
+
|
15
|
+
Updates each branch with the latest issue status on GitHub.
|
16
|
+
|
17
|
+
Synopsis
|
18
|
+
--------
|
19
|
+
|
20
|
+
twig gh-update
|
21
|
+
|
22
|
+
Description
|
23
|
+
-----------
|
24
|
+
|
25
|
+
Updates each branch with the latest issue status on GitHub.
|
26
|
+
|
27
|
+
To customize the GitHub URI prefix (e.g., for GitHub Enterprise
|
28
|
+
installations), set GitHub options in `~/.twigconfig`:
|
29
|
+
|
30
|
+
github-uri-prefix: http://example-enterprise.github.com
|
31
|
+
github-api-uri-prefix: http://example-enterprise.github.com
|
32
|
+
|
33
|
+
See also
|
34
|
+
--------
|
35
|
+
|
36
|
+
twig-gh-open
|
37
|
+
twig-gh-open-issue
|
38
|
+
|
39
|
+
Subcommand for Twig: <http://rondevera.github.io/twig/>
|
40
|
+
Author: Ron DeVera <http://rondevera.com>
|
41
|
+
|
42
|
+
HELP
|
43
|
+
end
|
44
|
+
|
45
|
+
args = ARGV.dup
|
46
|
+
|
47
|
+
if args.include?('--help')
|
48
|
+
puts help_content
|
49
|
+
exit
|
50
|
+
end
|
51
|
+
|
26
52
|
twig = Twig.new(:read_options => true)
|
27
53
|
|
28
54
|
Twig::GithubRepo.new do |gh_repo|
|
@@ -39,7 +65,7 @@ Twig::GithubRepo.new do |gh_repo|
|
|
39
65
|
]
|
40
66
|
user_agent = "Twig/#{Twig::VERSION} (for Git; <#{Twig::HOMEPAGE}>)"
|
41
67
|
|
42
|
-
error = "\n\nERROR: Couldn't get open issues from GitHub."
|
68
|
+
error = "\n\nERROR: Couldn't get open issues from GitHub." \
|
43
69
|
"\n- API endpoints: " << issues_uris.map { |uri| "<#{uri}>" }.join(', ')
|
44
70
|
|
45
71
|
begin
|
@@ -62,7 +88,7 @@ Twig::GithubRepo.new do |gh_repo|
|
|
62
88
|
abort error + "\n- Response: #{response.code}"
|
63
89
|
end
|
64
90
|
end
|
65
|
-
rescue OpenSSL::SSL::SSLError
|
91
|
+
rescue OpenSSL::SSL::SSLError
|
66
92
|
abort error
|
67
93
|
end
|
68
94
|
|
data/bin/twig-help
CHANGED
@@ -1,8 +1,52 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
# Subcommand for Twig: <http://rondevera.github.io/twig/>
|
6
|
-
# Author: Ron DeVera <http://rondevera.com>
|
3
|
+
def help_content
|
4
|
+
<<-HELP
|
7
5
|
|
8
|
-
|
6
|
+
twig-help
|
7
|
+
=========
|
8
|
+
|
9
|
+
Provides help for Twig and its subcommands.
|
10
|
+
|
11
|
+
Synopsis
|
12
|
+
--------
|
13
|
+
|
14
|
+
twig help [<subcommand>]
|
15
|
+
|
16
|
+
Description
|
17
|
+
-----------
|
18
|
+
|
19
|
+
Shows help content for Twig and for its built-in subcommands.
|
20
|
+
|
21
|
+
To make a custom subcommand work with this system (e.g.,
|
22
|
+
`twig help my-subcommand`), simply add `--help` support to the subcommand
|
23
|
+
(e.g., `twig my-subcommand --help`), and Twig will call it automatically.
|
24
|
+
|
25
|
+
Examples
|
26
|
+
--------
|
27
|
+
|
28
|
+
Show help content for Twig:
|
29
|
+
|
30
|
+
twig help
|
31
|
+
|
32
|
+
Show help content for a Twig subcommand, e.g., `twig-rebase`:
|
33
|
+
|
34
|
+
twig help rebase
|
35
|
+
|
36
|
+
Subcommand for Twig: <http://rondevera.github.io/twig/>
|
37
|
+
Author: Ron DeVera <http://rondevera.com>
|
38
|
+
|
39
|
+
HELP
|
40
|
+
end
|
41
|
+
|
42
|
+
args = ARGV.dup
|
43
|
+
|
44
|
+
if args.include?('--help')
|
45
|
+
puts help_content
|
46
|
+
exit
|
47
|
+
end
|
48
|
+
|
49
|
+
subcommand = args[0] || ''
|
50
|
+
|
51
|
+
# If no subcommand was given, default to `twig --help`
|
52
|
+
exec("twig #{subcommand} --help")
|
data/bin/twig-init
CHANGED
@@ -1,15 +1,48 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
3
|
+
def help_content
|
4
|
+
<<-HELP
|
5
|
+
|
6
|
+
twig-init
|
7
|
+
=========
|
8
|
+
|
9
|
+
Runs all Twig setup commands.
|
10
|
+
|
11
|
+
Synopsis
|
12
|
+
--------
|
13
|
+
|
14
|
+
twig init
|
15
|
+
|
16
|
+
Description
|
17
|
+
-----------
|
18
|
+
|
19
|
+
Runs all setup commands. This is only needed once after installing Twig, and
|
20
|
+
affects all Git repositories.
|
21
|
+
|
22
|
+
See also
|
23
|
+
--------
|
24
|
+
|
25
|
+
twig-init-completion
|
26
|
+
twig-init-config
|
27
|
+
|
28
|
+
Subcommand for Twig: <http://rondevera.github.io/twig/>
|
29
|
+
Author: Ron DeVera <http://rondevera.com>
|
30
|
+
|
31
|
+
HELP
|
32
|
+
end
|
33
|
+
|
34
|
+
args = ARGV.dup
|
35
|
+
|
36
|
+
if args.include?('--help')
|
37
|
+
puts help_content
|
38
|
+
exit
|
39
|
+
end
|
40
|
+
|
41
|
+
commands = [
|
42
|
+
'echo',
|
43
|
+
'twig init-config',
|
44
|
+
'twig init-completion',
|
45
|
+
'echo "*** Twig is almost ready! Follow the steps above, ***"',
|
46
|
+
'echo "*** then run \`twig\` or \`twig help\` to get started. ***"'
|
47
|
+
]
|
48
|
+
exec commands.join(';')
|