twig 1.6 → 1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 360381819d893fa2d71b315d1c19a0c48e98132e
4
- data.tar.gz: 82c42e49a983d5a0539b29b9784b19daf35a21e4
3
+ data.tar.gz: 652595cdad13fa87f888765b0ba912f0d21b840b
4
+ metadata.gz: 74cf0612d43de9ade52a217d2845d0bd899e19b5
5
5
  SHA512:
6
- metadata.gz: d9b7ddf8e5904fc1a76bad82461d33e3e7b729a7ef243a65dcca2c22978c7ba2c0ede1cd35ca900674b3d0bb86ca3001600eb008ffe6c746364162c58a1d0aa2
7
- data.tar.gz: 8df02602a640c113ac00dd28f8321515ae2409f22d080d2cadec234c987c2dd8375e07e147faf1879a40e8673f7d87e32533424bad8b273ad7932ad7ec91e751
6
+ data.tar.gz: 25b82c034a5d398bb78f25280b58c42f51cfc86b2857bdd16256de5685863f0fdfcb5421231beab411c0d883b2cb46c6f3e4b57f3cd37e951d72331818eab831
7
+ metadata.gz: d62797278db061c8b5858c0bcc0517ec0e4f0bfe8d75e8e06b443a7f82a1f8767b2c6a46c245b55a0b3a34d2588dd8620654cd4406a3661b0b57fa5e6f36fb5e
data/.travis.yml CHANGED
@@ -1,5 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.1.2
4
+ - 2.1.1
3
5
  - 2.1.0
4
6
  - 2.0.0
5
7
  - 1.9.3
data/HISTORY.md CHANGED
@@ -1,6 +1,33 @@
1
1
  Twig
2
2
  ====
3
3
 
4
+ 1.7 (2014-07-29)
5
+ ----------------
6
+ * ENHANCEMENT: Expand `twig init` to also create a default `~/.twigconfig` file.
7
+ This uses a new `twig init-config` subcommand behind the scenes.
8
+ * ENHANCEMENT: Add `twig help <subcommand>` for showing help content for any
9
+ built-in Twig subcommand (e.g., `twig help rebase`). To make a custom
10
+ subcommand work with this system (e.g., `twig help my-subcommand`), simply add
11
+ `--help` support to the subcommand (e.g., `twig my-subcommand --help`), and
12
+ Twig will call it automatically.
13
+ * ENHANCEMENT: List built-in subcommands in `twig help` with short descriptions
14
+ of each. (GH-32)
15
+ * ENHANCEMENT: Support `twig rebase --autoconfirm` for skipping the prompt when
16
+ rebasing a branch onto its parent branch. To skip the prompt every time you
17
+ use `twig rebase`, add `twig-rebase-autoconfirm: true` to your
18
+ `~/.twigconfig`. (GH-24. Thanks [ljharb](https://github.com/ljharb) for the
19
+ idea!)
20
+ * ENHANCEMENT: Suggest `twig --all` if there are no matching branches. (GH-33)
21
+ * ENHANCEMENT: Add Ruby 2.1.1 and 2.1.2 to official list of supported Rubies.
22
+ * FIX: Don't require a Git repo for initialization (e.g., `twig init`) or for
23
+ showing help content (e.g., `twig help rebase`).
24
+ * FIX: Show units of time for relative time strings when not using English.
25
+ (GH-37, GH-38. Thanks [matteosister](https://github.com/matteosister)!)
26
+ * FIX: Handle special shell characters (e.g., backticks, dollar signs) in branch
27
+ names and property values.
28
+ * FIX: Disable unsupported string formatting in Windows. (GH-39. Thanks
29
+ [rcdailey](https://github.com/rcdailey) for the bug report!)
30
+
4
31
  1.6 (2014-03-04)
5
32
  ----------------
6
33
  * ENHANCEMENT: Add `--only-property <pattern>` and `--except-property <pattern>`
data/README.md CHANGED
@@ -5,9 +5,8 @@ Twig: Your personal Git branch assistant.
5
5
  [![Build Status](https://travis-ci.org/rondevera/twig.png?branch=development)](https://travis-ci.org/rondevera/twig)
6
6
 
7
7
  It's hard enough trying to remember the names of all of your Git branches. You
8
- also need those branches' issue tracker ids, issue statuses, and reminders of
9
- what to do next with each branch. `git branch` only lists them in alphabetical
10
- order, which just doesn't cut it.
8
+ also need their issue tracker ids, issue statuses, and reminders of what to do
9
+ next with each branch. `git branch` just isn't cutting it.
11
10
 
12
11
  **Twig shows you your most recent branches, and remembers branch details for
13
12
  you.** It supports subcommands, like automatically fetching statuses from your
@@ -32,9 +31,9 @@ Quick start
32
31
 
33
32
  gem install twig
34
33
 
35
- twig init # Sets up tab completion; one run works across all repos
36
- twig # Lists your branches
37
- twig --help # More info
34
+ twig init # Sets up tab completion; one run works across all repos
35
+ twig # Lists your branches
36
+ twig help # More info
38
37
 
39
38
 
40
39
  Usage
@@ -50,9 +49,9 @@ chronologically with their properties.
50
49
  * `twig <property> -b <branch>`: Get property for any branch
51
50
  * `twig <property> <value> -b <branch>`: Set property for any branch
52
51
  * `twig --unset <property> -b <branch>`: Unset property for any branch
53
- * `twig init`: Set up tab completion for `-b` and `--branch`; one run works across all repos
52
+ * `twig init`: Set up tab completion and `~/.twigconfig`; one runs works across all repos
54
53
  * `twig init-completion --force`: Update to the latest tab completion script
55
- * `twig --help`: More info
54
+ * `twig help`: More info
56
55
 
57
56
 
58
57
  Display options
@@ -71,7 +70,7 @@ Twig lists all of your branches by default (newest first), but you can filter
71
70
  them by age, name, and custom properties:
72
71
 
73
72
  * `twig --max-days-old <age>`:
74
- Only list branches below a given age
73
+ Only list branches that were touched in the last # days
75
74
  * `twig --only-branch <pattern>`:
76
75
  Only list branches whose name matches a given pattern
77
76
  * `twig --except-branch <pattern>`:
@@ -80,18 +79,30 @@ them by age, name, and custom properties:
80
79
  Only list branches with a given property that matches a given pattern
81
80
  * `twig --except-<property> <pattern>`:
82
81
  Don't list branches with a given property that matches a given pattern
82
+ * `twig --only-property <pattern>`:
83
+ Only show columns for properties whose name matches a given pattern
84
+ * `twig --except-property <pattern>`:
85
+ Don't show columns for properties whose name matches a given pattern
83
86
  * `twig --all`:
84
87
  List all branches regardless of other filtering options
85
88
 
86
- You can put your most frequently used options into `~/.twigconfig`, and they'll
87
- be automatically included when you run `twig`. Example:
89
+ Saving favorite options
90
+ -----------------------
91
+
92
+ Running `twig init` generates a `~/.twigconfig` file with default options.
93
+ Afterwards, you can put your most frequently used options into this file, and
94
+ they'll automatically be included when you run `twig`. For example:
88
95
 
89
96
  # ~/.twigconfig:
90
- except-branch: staging
97
+
98
+ # Display options:
91
99
  header-style: green bold
92
- max-days-old: 30
93
100
  reverse: true
94
101
 
102
+ # Filtering options:
103
+ except-branch: staging
104
+ max-days-old: 30
105
+
95
106
 
96
107
  Examples
97
108
  --------
@@ -179,11 +190,11 @@ current branch, you can use `twig checkout-child`:
179
190
  # checkout that branch:
180
191
  $ twig checkout-child
181
192
 
182
- # If the current branch has multiple child, Twig asks what to do:
193
+ # If the current branch has multiple child branches, Twig asks what to do:
183
194
  Checkout which child branch?
184
- 1. child-branch-1
185
- 2. child-branch-2
186
- 3. child-branch-3
195
+ 1. child-branch-1
196
+ 2. child-branch-2
197
+ 3. child-branch-3
187
198
  > 3
188
199
  Switched to branch 'child-branch-3'
189
200
 
@@ -298,6 +309,12 @@ More advanced usage:
298
309
  # Pass options through to `git rebase`:
299
310
  $ twig rebase -i
300
311
 
312
+ # Skip the prompt when rebasing:
313
+ $ twig rebase --autoconfirm
314
+
315
+ # Skip the prompt every time you run `twig rebase`:
316
+ $ echo 'twig-rebase-autoconfirm: true' >> ~/.twigconfig
317
+
301
318
 
302
319
  twig gh-open
303
320
  ------------
@@ -311,7 +328,7 @@ open a browser window if possible:
311
328
  GitHub URL: https://github.com/myname/myproject
312
329
 
313
330
  For GitHub Enterprise or other installations, you can change
314
- `https://github.com` by setting `github-uri-prefix` in `~/.twigrc`.
331
+ `https://github.com` by setting `github-uri-prefix` in `~/.twigconfig`.
315
332
 
316
333
 
317
334
  twig gh-open-issue
@@ -329,7 +346,7 @@ subcommand to view that issue on GitHub:
329
346
  GitHub issue URL: https://github.com/myname/myproject/issues/222
330
347
 
331
348
  For GitHub Enterprise or other installations, you can change
332
- `https://github.com` by setting `github-uri-prefix` in `~/.twigrc`.
349
+ `https://github.com` by setting `github-uri-prefix` in `~/.twigconfig`.
333
350
 
334
351
 
335
352
  twig gh-update
@@ -369,7 +386,7 @@ Run `twig gh-update` periodically to keep up with GitHub issues locally.
369
386
 
370
387
  For GitHub Enterprise or other installations, you can change the default
371
388
  `https://api.github.com` endpoint prefix by setting `github-api-uri-prefix` in
372
- `~/.twigrc`.
389
+ `~/.twigconfig`.
373
390
 
374
391
 
375
392
  Writing a subcommand
@@ -408,8 +425,9 @@ add it to the [Twig wiki][wiki]!
408
425
  More info
409
426
  =========
410
427
 
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.
428
+ * **Requirements:** Tested with Git 1.8.4+ and Ruby 1.8.7+ (see
429
+ [Travis CI config][travis-yml]) on OS X and other *nix systems. Might work
430
+ with older software and other systems, but it's not guaranteed.
413
431
  * **Contributing:** Found a bug or have a suggestion? [Please open an
414
432
  issue][issues] or ping [@ronalddevera on Twitter][twitter]. If you want to
415
433
  hack on some features or contribute a subcommand you've written, feel free to
@@ -426,3 +444,4 @@ More info
426
444
  [contributing]: https://github.com/rondevera/twig/blob/master/CONTRIBUTING.md
427
445
  [history]: https://github.com/rondevera/twig/blob/master/HISTORY.md
428
446
  [license]: https://github.com/rondevera/twig/blob/master/LICENSE.md
447
+ [travis-yml]: https://github.com/rondevera/twig/blob/development/.travis.yml
data/bin/twig CHANGED
@@ -1,17 +1,25 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # Entry point for Twig: <http://rondevera.github.io/twig/>
4
- # More info: `twig --help`
4
+ # More info: `twig help`
5
5
 
6
6
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'twig'))
7
7
 
8
- repo_required = ARGV != ['--help'] && ARGV != ['help'] && ARGV != ['--version']
8
+ args = ARGV.dup
9
+ repo_required =
10
+ !args.include?('--help') &&
11
+ args[0] != 'help' && # e.g., `twig help <subcommand>`
12
+ args != ['--version'] &&
13
+ args != ['init'] &&
14
+ args != ['init-completion'] &&
15
+ args != ['init-completion-bash'] &&
16
+ args != ['init-config']
9
17
 
10
18
  if repo_required && !Twig.repo?
11
- abort "Current directory is not a git repository."
19
+ abort 'Current directory is not a git repository.'
12
20
  end
13
21
 
14
22
  # Gettin' twiggy wit' it.
15
23
  twig = Twig.new
16
24
  twig.read_config_file!
17
- twig.read_cli_args!(ARGV)
25
+ twig.read_cli_args!(args)
@@ -1,26 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
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
3
  require 'rubygems'
25
4
  require 'twig'
26
5
 
@@ -28,10 +7,60 @@ def checkout_branch(branch_name)
28
7
  `git checkout "#{branch_name}"`
29
8
  end
30
9
 
10
+ def help_content
11
+ <<-HELP
12
+
13
+ twig-checkout-child
14
+ ===================
15
+
16
+ Checks out a branch's child branch, if any.
17
+
18
+ Synopsis
19
+ --------
20
+
21
+ twig checkout-child [-b|--branch <branch>]
22
+
23
+ Description
24
+ -----------
25
+
26
+ Checks out the current branch's child branch, if any, based on the child's
27
+ `diff-branch` property. If the current branch has multiple child branches,
28
+ this subcommand lists all of them and prompts for a selection.
29
+
30
+ You can use this with `twig checkout-parent` to traverse your tree of
31
+ branches.
32
+
33
+ Options
34
+ -------
35
+
36
+ `-b` or `--branch`: Checks out the child branch for the given branch, rather
37
+ than the current branch.
38
+
39
+ See also
40
+ --------
41
+
42
+ twig-checkout-parent
43
+ twig-create-branch
44
+
45
+ Subcommand for Twig: <http://rondevera.github.io/twig/>
46
+ Author: Ron DeVera <http://rondevera.com>
47
+
48
+ HELP
49
+ end
50
+
51
+ args = ARGV.dup
52
+
53
+ if args.include?('--help')
54
+ puts help_content
55
+ exit
56
+ end
57
+
31
58
  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)
59
+ target_branch_name = twig.target_branch_name
60
+ target_branch_regexp = Regexp.new("\\A#{target_branch_name}\\z")
61
+ parent_property = Twig::Branch::PARENT_PROPERTY
62
+
63
+ twig.set_option(:property_only, parent_property.to_sym => target_branch_regexp)
35
64
  child_branch_names = twig.branches
36
65
 
37
66
  if child_branch_names.size > 1
@@ -46,5 +75,7 @@ if child_branch_names.size > 1
46
75
  elsif child_branch_names.size == 1
47
76
  checkout_branch(child_branch_names.first)
48
77
  else
49
- abort "There are no branches whose `diff-branch` property is `#{target_branch}`."
78
+ abort %{The branch "#{target_branch_name}" has no known child branches.\n} \
79
+ "To set this as parent branch for some child branch, run:\n\n" \
80
+ " twig diff-branch #{target_branch_name} -b <child branch name>"
50
81
  end
@@ -1,35 +1,63 @@
1
1
  #!/usr/bin/env ruby
2
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
3
  require 'rubygems'
24
4
  require 'twig'
25
5
 
6
+ def help_content
7
+ <<-HELP
8
+
9
+ twig-checkout-parent
10
+ ====================
11
+
12
+ Checks out a branch's parent branch.
13
+
14
+ Synopsis
15
+ --------
16
+
17
+ twig checkout-parent [-b|--branch <branch>]
18
+
19
+ Description
20
+ -----------
21
+
22
+ Checks out the current branch's parent branch, if any, based on the current
23
+ branch's `diff-branch` property.
24
+
25
+ You can use this with `twig checkout-child` to traverse your tree of branches.
26
+
27
+ Options
28
+ -------
29
+
30
+ `-b` or `--branch`: Checks out the parent branch of the given branch, rather
31
+ than the current branch.
32
+
33
+ See also
34
+ --------
35
+
36
+ twig-checkout-child
37
+ twig-create-branch
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
- parent_property = 'diff-branch'
28
- target_branch = twig.target_branch_name
29
- parent_branch = twig.get_branch_property(target_branch, parent_property) || ''
53
+ target_branch = twig.target_branch
54
+ parent_branch_name = target_branch.parent_name
30
55
 
31
- if parent_branch.empty?
32
- abort %{The branch "#{target_branch}" does not have the property "#{parent_property}".}
56
+ if parent_branch_name && !parent_branch_name.empty?
57
+ exec %{git checkout "#{parent_branch_name}"}
33
58
  else
34
- exec %{git checkout "#{parent_branch}"}
59
+ parent_property = Twig::Branch::PARENT_PROPERTY
60
+ abort %{The branch "#{target_branch}" has no known parent branch.\n} \
61
+ "To set the parent branch, run:\n\n" \
62
+ " twig diff-branch <parent branch name> -b #{target_branch}"
35
63
  end
@@ -1,20 +1,45 @@
1
1
  #!/usr/bin/env ruby
2
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
3
+ def help_content
4
+ <<-HELP
5
+
6
+ twig-create-branch
7
+ ==================
8
+
9
+ Creates a branch and sets its `diff-branch` property to the previous branch name.
10
+
11
+ Synopsis
12
+ --------
13
+
14
+ twig create-branch <branch>
15
+
16
+ Description
17
+ -----------
18
+
19
+ Creates a branch with the given name, and sets the new branch's `diff-branch`
20
+ property to the previous branch's name. This allows for traversing the branch
21
+ tree with `twig checkout-parent` and `twig checkout-child`.
22
+
23
+ See also
24
+ --------
25
+
26
+ twig-checkout-child
27
+ twig-checkout-parent
28
+
29
+ Subcommand for Twig: <http://rondevera.github.io/twig/>
30
+ Author: Ron DeVera <http://rondevera.com>
31
+
32
+ HELP
33
+ end
34
+
35
+ args = ARGV.dup
36
+
37
+ if args.include?('--help')
38
+ puts help_content
39
+ exit
40
+ end
41
+
42
+ new_branch_name = (args[0] || '').strip
18
43
  abort 'Usage: twig create-branch <branch name>' if new_branch_name.empty?
19
44
 
20
45
  current_branch_name = `git rev-parse --abbrev-ref HEAD`.strip