twig 1.5 → 1.6
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 +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +2 -0
- data/CONTRIBUTING.md +5 -3
- data/HISTORY.md +23 -0
- data/LICENSE.md +1 -1
- data/README.md +98 -12
- data/bin/twig +1 -0
- data/bin/twig-checkout-child +50 -0
- data/bin/twig-checkout-parent +35 -0
- data/bin/twig-create-branch +24 -0
- data/bin/twig-diff +15 -12
- data/bin/twig-gh-open +14 -5
- data/bin/twig-gh-open-issue +19 -12
- data/bin/twig-gh-update +14 -4
- data/bin/twig-init +15 -0
- data/bin/twig-init-completion +14 -2
- data/bin/twig-init-completion-bash +11 -3
- data/bin/twig-rebase +15 -12
- data/lib/twig.rb +40 -20
- data/lib/twig/branch.rb +34 -13
- data/lib/twig/cli.rb +52 -9
- data/lib/twig/commit_time.rb +1 -1
- data/lib/twig/display.rb +6 -8
- data/lib/twig/options.rb +25 -24
- data/lib/twig/version.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/twig/branch_spec.rb +85 -6
- data/spec/twig/cli_spec.rb +90 -35
- data/spec/twig/commit_time_spec.rb +4 -0
- data/spec/twig/display_spec.rb +57 -7
- data/spec/twig/options_spec.rb +33 -16
- data/spec/twig_spec.rb +53 -50
- data/twig.gemspec +17 -10
- metadata +32 -48
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 360381819d893fa2d71b315d1c19a0c48e98132e
|
4
|
+
data.tar.gz: 82c42e49a983d5a0539b29b9784b19daf35a21e4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d9b7ddf8e5904fc1a76bad82461d33e3e7b729a7ef243a65dcca2c22978c7ba2c0ede1cd35ca900674b3d0bb86ca3001600eb008ffe6c746364162c58a1d0aa2
|
7
|
+
data.tar.gz: 8df02602a640c113ac00dd28f8321515ae2409f22d080d2cadec234c987c2dd8375e07e147faf1879a40e8673f7d87e32533424bad8b273ad7932ad7ec91e751
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CONTRIBUTING.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
How to contribute
|
2
2
|
=================
|
3
3
|
|
4
|
-
Let's make life easier for people
|
4
|
+
Let's make life easier for people who have lots of Git branches.
|
5
5
|
|
6
6
|
Found a bug or have a suggestion? [Please open an issue][issues] or ping
|
7
7
|
[@ronalddevera on Twitter][twitter].
|
@@ -17,8 +17,9 @@ If you want to hack on some code, even better! Here are the basics:
|
|
17
17
|
4. Run the tests to make sure that they pass on your machine: `bundle && rake`
|
18
18
|
5. Add one or more failing tests for your feature or bug fix.
|
19
19
|
6. Write your feature or bug fix to make the test(s) pass.
|
20
|
-
* Tests should pass
|
21
|
-
you can
|
20
|
+
* Tests should pass for the Ruby versions listed in
|
21
|
+
[.travis.yml][travis.yml], which you can confirm with [rvm][rvm] or
|
22
|
+
[rbenv][rbenv].
|
22
23
|
* Keep the branch focused on a single topic, rather than covering multiple
|
23
24
|
features or bug fixes in a single branch. This makes branches quicker to
|
24
25
|
review and merge.
|
@@ -34,3 +35,4 @@ Thanks for contributing!
|
|
34
35
|
[dev branch]: https://github.com/rondevera/twig/commits/development
|
35
36
|
[rvm]: https://rvm.io/
|
36
37
|
[rbenv]: http://rbenv.org/
|
38
|
+
[travis.yml]: https://github.com/rondevera/twig/blob/master/.travis.yml
|
data/HISTORY.md
CHANGED
@@ -1,6 +1,29 @@
|
|
1
1
|
Twig
|
2
2
|
====
|
3
3
|
|
4
|
+
1.6 (2014-03-04)
|
5
|
+
----------------
|
6
|
+
* ENHANCEMENT: Add `--only-property <pattern>` and `--except-property <pattern>`
|
7
|
+
for including/excluding property names in list view and JSON view. Useful for
|
8
|
+
hiding properties that are frequently too long to show in list view (e.g.,
|
9
|
+
`todo`), or for hiding groups of properties that are just issue tracker
|
10
|
+
metadata. (GH-25. Thanks [slucero](https://github.com/slucero) for the idea!)
|
11
|
+
* ENHANCEMENT: Add `twig init` subcommand, the new recommended way to set up
|
12
|
+
Twig after installing the gem.
|
13
|
+
* ENHANCEMENT: Add `twig checkout-parent` subcommand, which checks out the
|
14
|
+
current branch's parent branch, if any, based on its `diff-branch` property.
|
15
|
+
(GH-34)
|
16
|
+
* ENHANCEMENT: Add `twig checkout-child` subcommand, which checks out the
|
17
|
+
current branch's child branch, if any, based on the child's `diff-branch`
|
18
|
+
property. If the current branch has multiple child branches, this subcommand
|
19
|
+
lists all of them and prompts for a selection. (GH-35)
|
20
|
+
* ENHANCEMENT: Add `twig create-branch` subcommand, which creates a branch off
|
21
|
+
of the current branch, and sets the child branch's `diff-branch` property
|
22
|
+
automatically.
|
23
|
+
* FIX: Fix `(1y ago)` (previously displayed as `(1 ago)`) in branch list view.
|
24
|
+
* FIX: Make `property` a reserved property name, along with `branch`, `merge`,
|
25
|
+
`rebase`, and `remote`.
|
26
|
+
|
4
27
|
1.5 (2013-11-21)
|
5
28
|
----------------
|
6
29
|
* ENHANCEMENT: Add `--format=json` option for printing branch data as JSON
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -27,11 +27,15 @@ Here's how Twig looks in action:
|
|
27
27
|
2013-01-20 19:45:42 (6d ago) - - - master
|
28
28
|
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
Quick start
|
31
|
+
===========
|
32
32
|
|
33
33
|
gem install twig
|
34
34
|
|
35
|
+
twig init # Sets up tab completion; one run works across all repos
|
36
|
+
twig # Lists your branches
|
37
|
+
twig --help # More info
|
38
|
+
|
35
39
|
|
36
40
|
Usage
|
37
41
|
=====
|
@@ -46,7 +50,7 @@ chronologically with their properties.
|
|
46
50
|
* `twig <property> -b <branch>`: Get property for any branch
|
47
51
|
* `twig <property> <value> -b <branch>`: Set property for any branch
|
48
52
|
* `twig --unset <property> -b <branch>`: Unset property for any branch
|
49
|
-
* `twig init
|
53
|
+
* `twig init`: Set up tab completion for `-b` and `--branch`; one run works across all repos
|
50
54
|
* `twig init-completion --force`: Update to the latest tab completion script
|
51
55
|
* `twig --help`: More info
|
52
56
|
|
@@ -86,6 +90,7 @@ be automatically included when you run `twig`. Example:
|
|
86
90
|
except-branch: staging
|
87
91
|
header-style: green bold
|
88
92
|
max-days-old: 30
|
93
|
+
reverse: true
|
89
94
|
|
90
95
|
|
91
96
|
Examples
|
@@ -161,6 +166,87 @@ properties. You can [write your own](#writing-a-subcommand), but here are some
|
|
161
166
|
subcommands that Twig comes with.
|
162
167
|
|
163
168
|
|
169
|
+
twig checkout-child
|
170
|
+
-------------------
|
171
|
+
|
172
|
+
Twig uses each branch's `diff-branch` property to remember its parent branch so
|
173
|
+
you don't have to. If you need to check out one of the child branches for your
|
174
|
+
current branch, you can use `twig checkout-child`:
|
175
|
+
|
176
|
+
$ git checkout feature-branch
|
177
|
+
|
178
|
+
# Look for any branch whose `diff-branch` property is `feature-branch`, and
|
179
|
+
# checkout that branch:
|
180
|
+
$ twig checkout-child
|
181
|
+
|
182
|
+
# If the current branch has multiple child, Twig asks what to do:
|
183
|
+
Checkout which child branch?
|
184
|
+
1. child-branch-1
|
185
|
+
2. child-branch-2
|
186
|
+
3. child-branch-3
|
187
|
+
> 3
|
188
|
+
Switched to branch 'child-branch-3'
|
189
|
+
|
190
|
+
More advanced usage:
|
191
|
+
|
192
|
+
# Switch to a child branch of any other branch:
|
193
|
+
$ twig checkout-child -b other-feature-branch
|
194
|
+
Switched to branch 'other-child-branch'
|
195
|
+
|
196
|
+
You can use this with `twig checkout-parent` and `twig create-branch` to
|
197
|
+
traverse your tree of branches.
|
198
|
+
|
199
|
+
|
200
|
+
twig checkout-parent
|
201
|
+
--------------------
|
202
|
+
|
203
|
+
If your branch has a `diff-branch` property, you can use `twig checkout-parent`
|
204
|
+
to quickly switch to that branch:
|
205
|
+
|
206
|
+
$ git checkout branch2
|
207
|
+
|
208
|
+
# Remember your branch's diff branch:
|
209
|
+
$ twig diff-branch branch1
|
210
|
+
Saved property "diff-branch" as "branch1" for branch "branch2".
|
211
|
+
|
212
|
+
# Later, switch from branch2 (the current branch) to its parent branch:
|
213
|
+
$ twig checkout-parent
|
214
|
+
Switched to branch 'branch1'
|
215
|
+
|
216
|
+
More advanced usage:
|
217
|
+
|
218
|
+
# Switch to the parent branch of any other branch:
|
219
|
+
$ twig checkout-parent -b other-branch-2
|
220
|
+
Switched to branch 'other-branch-1'
|
221
|
+
|
222
|
+
You can use this with `twig checkout-child` and `twig create-branch` to traverse
|
223
|
+
your tree of branches.
|
224
|
+
|
225
|
+
|
226
|
+
twig create-branch
|
227
|
+
------------------
|
228
|
+
|
229
|
+
When creating a branch, you can use `twig create-branch` to create a child
|
230
|
+
branch and set its `diff-branch` property automatically:
|
231
|
+
|
232
|
+
$ git checkout master
|
233
|
+
$ twig create-branch my-branch
|
234
|
+
Branch my-branch set up to track local branch master.
|
235
|
+
Switched to a new branch 'my-branch'
|
236
|
+
Saved property "diff-branch" as "master" for branch "my-branch".
|
237
|
+
|
238
|
+
# Confirm that the new branch's `diff-branch` is its parent:
|
239
|
+
$ twig diff-branch
|
240
|
+
master
|
241
|
+
|
242
|
+
# Check out the new branch's parent:
|
243
|
+
$ twig checkout-parent
|
244
|
+
Switched to branch 'master'
|
245
|
+
|
246
|
+
You can use this with `twig checkout-child` and `twig checkout-parent` to
|
247
|
+
traverse your tree of branches.
|
248
|
+
|
249
|
+
|
164
250
|
twig diff
|
165
251
|
---------
|
166
252
|
|
@@ -176,7 +262,7 @@ to remember which branch to diff against. `twig diff` makes it easy:
|
|
176
262
|
# Generate a diff between branch1 (the current branch) and branch2:
|
177
263
|
$ twig diff
|
178
264
|
|
179
|
-
More usage:
|
265
|
+
More advanced usage:
|
180
266
|
|
181
267
|
# Generate a diff between any given branch and its `diff-branch`:
|
182
268
|
$ twig diff my-other-branch
|
@@ -191,8 +277,8 @@ More usage:
|
|
191
277
|
twig rebase
|
192
278
|
-----------
|
193
279
|
|
194
|
-
If you have a stack of branches that you need to rebase in the same order
|
195
|
-
`twig rebase` simplifies the process:
|
280
|
+
If you have a stack of branches that you need to rebase in the same order every
|
281
|
+
time, `twig rebase` simplifies the process:
|
196
282
|
|
197
283
|
$ git checkout branch2
|
198
284
|
|
@@ -204,7 +290,7 @@ If you have a stack of branches that you need to rebase in the same order,
|
|
204
290
|
$ twig rebase
|
205
291
|
Rebase "branch2" onto "development"? (y/n)
|
206
292
|
|
207
|
-
More usage:
|
293
|
+
More advanced usage:
|
208
294
|
|
209
295
|
# Rebase any given branch onto its `diff-branch`:
|
210
296
|
$ twig rebase my-other-branch
|
@@ -292,15 +378,15 @@ Writing a subcommand
|
|
292
378
|
You can write any Twig subcommand that fits your own Git workflow. To write a
|
293
379
|
Twig subcommand:
|
294
380
|
|
295
|
-
1. Write a script
|
381
|
+
1. Write a script—any language will do. (If you want to take advantage of
|
296
382
|
Twig's option parsing and branch processing, you'll need Ruby. See
|
297
|
-
[`bin/twig-
|
383
|
+
[`bin/twig-checkout-parent`][twig-checkout-parent] for an example.)
|
298
384
|
2. Save it with the `twig-` prefix in your `$PATH`,
|
299
385
|
e.g., `~/bin/twig-my-subcommand`.
|
300
386
|
3. Make it executable: `chmod ugo+x ~/bin/twig-my-subcommand`
|
301
387
|
4. Run your subcommand: `twig my-subcommand` (with a *space* after `twig`)
|
302
388
|
|
303
|
-
[twig-
|
389
|
+
[twig-checkout-parent]: https://github.com/rondevera/twig/blob/master/bin/twig-checkout-parent
|
304
390
|
|
305
391
|
Some ideas for subcommands:
|
306
392
|
|
@@ -322,8 +408,8 @@ add it to the [Twig wiki][wiki]!
|
|
322
408
|
More info
|
323
409
|
=========
|
324
410
|
|
325
|
-
* **Requirements:** Tested with Git 1.
|
326
|
-
works with older software, but it's not guaranteed.
|
411
|
+
* **Requirements:** Tested with Git 1.7.12+ and Ruby 1.8.7, 1.9.2, 1.9.3, 2.0.0,
|
412
|
+
and 2.1.0. Probably works with older software, but it's not guaranteed.
|
327
413
|
* **Contributing:** Found a bug or have a suggestion? [Please open an
|
328
414
|
issue][issues] or ping [@ronalddevera on Twitter][twitter]. If you want to
|
329
415
|
hack on some features or contribute a subcommand you've written, feel free to
|
data/bin/twig
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Synopsis:
|
4
|
+
#
|
5
|
+
# twig checkout-child [-b|--branch <branch>]
|
6
|
+
#
|
7
|
+
# Description:
|
8
|
+
#
|
9
|
+
# Checks out the current branch's child branch, if any, based on the child's
|
10
|
+
# `diff-branch` property. If the current branch has multiple child branches,
|
11
|
+
# this subcommand lists all of them and prompts for a selection.
|
12
|
+
#
|
13
|
+
# You can use this with `twig checkout-parent` to traverse your tree of
|
14
|
+
# branches.
|
15
|
+
#
|
16
|
+
# Options:
|
17
|
+
#
|
18
|
+
# `-b` or `--branch`: Checks out the child branch for the given branch, rather
|
19
|
+
# than the current branch.
|
20
|
+
#
|
21
|
+
# Subcommand for Twig: <http://rondevera.github.io/twig/>
|
22
|
+
# Author: Ron DeVera <http://rondevera.com>
|
23
|
+
|
24
|
+
require 'rubygems'
|
25
|
+
require 'twig'
|
26
|
+
|
27
|
+
def checkout_branch(branch_name)
|
28
|
+
`git checkout "#{branch_name}"`
|
29
|
+
end
|
30
|
+
|
31
|
+
twig = Twig.new(:read_options => true)
|
32
|
+
target_branch = twig.target_branch_name
|
33
|
+
target_branch_regexp = Regexp.new("\\A#{target_branch}\\z")
|
34
|
+
twig.set_option(:property_only, :'diff-branch' => target_branch_regexp)
|
35
|
+
child_branch_names = twig.branches
|
36
|
+
|
37
|
+
if child_branch_names.size > 1
|
38
|
+
prompt = 'Checkout which child branch?'
|
39
|
+
child_branch_name = Twig::Cli.prompt_with_choices(prompt, child_branch_names)
|
40
|
+
|
41
|
+
if child_branch_name
|
42
|
+
checkout_branch(child_branch_name)
|
43
|
+
else
|
44
|
+
abort 'No child branch selected.'
|
45
|
+
end
|
46
|
+
elsif child_branch_names.size == 1
|
47
|
+
checkout_branch(child_branch_names.first)
|
48
|
+
else
|
49
|
+
abort "There are no branches whose `diff-branch` property is `#{target_branch}`."
|
50
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Synopsis:
|
4
|
+
#
|
5
|
+
# twig checkout-parent [-b|--branch <branch>]
|
6
|
+
#
|
7
|
+
# Description:
|
8
|
+
#
|
9
|
+
# Checks out the current branch's parent branch, if any, based on the current
|
10
|
+
# branch's `diff-branch` property.
|
11
|
+
#
|
12
|
+
# You can use this with `twig checkout-child` to traverse your tree of
|
13
|
+
# branches.
|
14
|
+
#
|
15
|
+
# Options:
|
16
|
+
#
|
17
|
+
# `-b` or `--branch`: Checks out the parent branch of the given branch, rather
|
18
|
+
# than the current branch.
|
19
|
+
#
|
20
|
+
# Subcommand for Twig: <http://rondevera.github.io/twig/>
|
21
|
+
# Author: Ron DeVera <http://rondevera.com>
|
22
|
+
|
23
|
+
require 'rubygems'
|
24
|
+
require 'twig'
|
25
|
+
|
26
|
+
twig = Twig.new(:read_options => true)
|
27
|
+
parent_property = 'diff-branch'
|
28
|
+
target_branch = twig.target_branch_name
|
29
|
+
parent_branch = twig.get_branch_property(target_branch, parent_property) || ''
|
30
|
+
|
31
|
+
if parent_branch.empty?
|
32
|
+
abort %{The branch "#{target_branch}" does not have the property "#{parent_property}".}
|
33
|
+
else
|
34
|
+
exec %{git checkout "#{parent_branch}"}
|
35
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Synopsis:
|
4
|
+
#
|
5
|
+
# twig create-branch <branch>
|
6
|
+
#
|
7
|
+
# Description:
|
8
|
+
#
|
9
|
+
# Creates a branch with the given name, and sets the new branch's
|
10
|
+
# `diff-branch` property to the previous branch's name. This allows for
|
11
|
+
# traversing the branch tree with `twig checkout-parent` and
|
12
|
+
# `twig checkout-child`.
|
13
|
+
#
|
14
|
+
# Subcommand for Twig: <http://rondevera.github.io/twig/>
|
15
|
+
# Author: Ron DeVera <http://rondevera.com>
|
16
|
+
|
17
|
+
new_branch_name = (ARGV[0] || '').strip
|
18
|
+
abort 'Usage: twig create-branch <branch name>' if new_branch_name.empty?
|
19
|
+
|
20
|
+
current_branch_name = `git rev-parse --abbrev-ref HEAD`.strip
|
21
|
+
|
22
|
+
cmd = %{git checkout -b "#{new_branch_name}"}
|
23
|
+
cmd << %{ && twig diff-branch "#{current_branch_name}"}
|
24
|
+
exec(cmd)
|
data/bin/twig-diff
CHANGED
@@ -1,24 +1,27 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
#
|
3
|
+
# Synopsis:
|
4
4
|
#
|
5
|
-
#
|
5
|
+
# twig diff [<branch>] [<options>]
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# Description:
|
8
8
|
#
|
9
|
-
# - `twig diff`:
|
10
9
|
# Shows the diff between the current branch and its `diff-branch` property.
|
10
|
+
# All options are passed through to `git-diff`.
|
11
11
|
#
|
12
|
-
#
|
13
|
-
# Shows the diff between the current branch and its `diff-branch`, and passes
|
14
|
-
# options through to `git-diff`, e.g., `twig diff --stat`.
|
12
|
+
# Examples:
|
15
13
|
#
|
16
|
-
#
|
17
|
-
# Shows the diff between the given branch and its `diff-branch` property.
|
14
|
+
# Show diff stats between the current branch and its `diff-branch`:
|
18
15
|
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
16
|
+
# twig diff --stat
|
17
|
+
#
|
18
|
+
# Show the diff between the given branch and its `diff-branch`:
|
19
|
+
#
|
20
|
+
# twig diff my_branch
|
21
|
+
#
|
22
|
+
# Show diff stats between the given branch and its `diff-branch`:
|
23
|
+
#
|
24
|
+
# twig diff my_branch --stat
|
22
25
|
#
|
23
26
|
# Subcommand for Twig: <http://rondevera.github.io/twig/>
|
24
27
|
# Author: Ron DeVera <http://rondevera.com>
|
data/bin/twig-gh-open
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
#
|
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
|
4
16
|
#
|
5
17
|
# Subcommand for Twig: <http://rondevera.github.io/twig/>
|
6
18
|
# Author: Ron DeVera <http://rondevera.com>
|
@@ -10,10 +22,7 @@ require 'twig'
|
|
10
22
|
require 'launchy'
|
11
23
|
|
12
24
|
Twig::GithubRepo.new do |gh_repo|
|
13
|
-
twig = Twig.new
|
14
|
-
twig.read_config_file!
|
15
|
-
twig.read_cli_options!(ARGV)
|
16
|
-
|
25
|
+
twig = Twig.new(:read_options => true)
|
17
26
|
gh_uri_prefix = twig.options[:github_uri_prefix]
|
18
27
|
url = "#{gh_uri_prefix}/#{gh_repo.username}/#{gh_repo.repository}"
|
19
28
|
|