git_commands 3.1.6 → 3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2115eda28aa459f4ca512e8e734cd859702da356
4
- data.tar.gz: 5950edb6f580c4c06f35cb763a3f75e746ed15d5
3
+ metadata.gz: b56d1810b535ad9bacd7d58b1dd1c68ef6f431f0
4
+ data.tar.gz: a1f27d3bf68f8f8c1293acc5f2ef24fc9faa83b1
5
5
  SHA512:
6
- metadata.gz: c247805c7a0fb198f760c499f1f1bcfd12ea911adec58b8366e5b8b0058852ffd74bf0fc57afffd616ce6f13817f9aa7958e10a5638a7308f7f33036182a676a
7
- data.tar.gz: d44b3d70b5b9ecbe9f3e22e4cfd9d327c26d5fff177228684793eae31fd097c4be37f0cab2e684fca30fbe4ea481726cfc4881ed1458d39bf8ac9454b44e8fbd
6
+ metadata.gz: c0ad1209c4c0e95e1814134fc64a25433fc7f62c8e584c49bbea69913df58b75826d548683db648bebc16712e006955bed6f8eda8b7987653bf85dcc7f6b2ee1
7
+ data.tar.gz: c0f56e29eb44e2f35113379f6f3a9cc7b58e2831d89183bcb3278020069a937a0e8ada519aaae40bce114ac1b33f31cadd7b4a46a2e670008bf4b97e2ba29432
data/README.md CHANGED
@@ -2,11 +2,16 @@
2
2
  * [Workflow](#workflow)
3
3
  * [Scope](#scope)
4
4
  * [Installation](#installation)
5
+ * [git](#git)
5
6
  * [Usage](#usage)
6
- * [Help](#help)
7
- * [rebase](#rebase)
8
- * [purge](#purge)
9
- * [aggregate](#aggregate)
7
+ * [Arguments](#help)
8
+ * [Help](#help)
9
+ * [Repository](#repository)
10
+ * [Branches](#branches)
11
+ * [Commands](#commands)
12
+ * [rebase](#rebase)
13
+ * [purge](#purge)
14
+ * [aggregate](#aggregate)
10
15
 
11
16
  ## Workflow
12
17
  This script will facilitate adopting a subset of the branch-featuring workflow characterised by:
@@ -21,37 +26,61 @@ The scope of this gem is helping out in the following cases:
21
26
  * you need to quickly aggregate branches for a release
22
27
 
23
28
  ## Installation
24
- I assume you have GIT installed ;)
25
29
  Just install the gem to use the binaries commands.
26
30
  ```
27
31
  gem install git_commands
28
32
  ```
29
33
 
34
+ ### git
35
+ The library uses the Ruby command line execution to invoke the **git** command. I assume you have the GIT program on your path.
36
+
30
37
  ## Usage
31
38
  Here are the main commands:
32
39
 
33
- ### Help
34
- Each command come with a help option that can be displayed:
40
+ ### Arguments
41
+ All of the available commands come with the same set of arguments:
42
+
43
+ #### Help
44
+ Display the help of a specific command by:
35
45
 
36
46
  ```
37
47
  rebase --help
38
48
  Usage: rebase --repo=./Sites/oro --branches=feature/add_bin,fetaure/remove_rake_task
39
49
  -r, --repo=REPO The path to the existing GIT repository
40
- -b, --branches=BRANCHES The comma-separated list of branches or the path to a .branches files
50
+ -b, --branches=BRANCHES The comma-separated list of branches or the path to a file listing branches names on each line
41
51
  -h, --help Prints this help
42
52
  ```
43
53
 
44
- ### rebase
45
- This is probably the most useful command in case you have several branches to rebase with _origin/master_ frequently.
46
- A confirmation is asked to before rebasing.
54
+ #### Repository
55
+ You have to specify the path (absolute or relative) to the GIT repository you want to work with. The path must be a folder initialized as a valid GIT repository (a check via *rev-parse* is performed), otherwise an error is raised:
56
+
57
+ ```
58
+ rebase --repo=invalid
59
+ 'invalid' is not a valid GIT repository!
60
+ ```
61
+
62
+ #### Branches
63
+ Along with the repository you always have to specify the list of branches you want the command to interact with.
64
+ You have two main options here:
65
+
66
+ ##### List of branches
67
+ Specify a comma separated list of branch names:
47
68
 
48
69
  ```
49
- rebase --repo=~/Sites/greatest_hits --branches=feature/love_me_tender,feature/teddybear,feature/return_to_sender
70
+ rebase --branches=feature/love_me_tender,feature/teddybear,feature/return_to_sender
71
+
72
+ Loading branches file...
73
+ Successfully loaded 3 branches:
74
+ 01. feature/love_me_tender
75
+ 02. feature/teddybear
76
+ 03. feature/return_to_sender
50
77
  ```
51
78
 
52
- You can also specify as the *branches* argument a path to a file containing the branches names on each line, like this:
79
+ ##### Path to a names file
80
+ Specify a path (absolute or relative) to a file containing the branches names on each line:
53
81
 
54
- ```txt
82
+ File *./Sites/greatest_hits*:
83
+ ```
55
84
  feature/love_me_tender
56
85
  feature/teddybear
57
86
  feature/return_to_sender
@@ -59,22 +88,52 @@ feature/in_the_ghetto
59
88
  ```
60
89
 
61
90
  ```
62
- rebase --repo=~/Sites/greatest_hits --branches=~/greatest_hits/.branches
91
+ rebase --branches=./Sites/greatest_hits
92
+
93
+ Loading branches file...
94
+ Successfully loaded 4 branches:
95
+ 01. feature/love_me_tender
96
+ 02. feature/teddybear
97
+ 03. feature/return_to_sender
98
+ 04. feature/in_the_ghetto
99
+ ```
100
+
101
+ ##### Checking
102
+ Each loaded branch is validated for existence (via *rev-parse*), in case it does not an error is raised:
103
+
104
+ ```
105
+ rebase --repo=./Sites/greatest_hits --branches=noent
106
+
107
+ Loading branches file...
108
+ Branch 'noent' does not exist!
109
+ ```
110
+
111
+ ### Commands
112
+ Here are the available GIT commands:
113
+
114
+ #### rebase
115
+ This is probably the most useful command in case you have several branches to rebase with _origin/master_ frequently.
116
+ A confirmation is asked to before rebasing.
117
+
118
+ ```
119
+ rebase --repo=./Sites/greatest_hits --branches=feature/love_me_tender,feature/teddybear,feature/return_to_sender
120
+ ...
63
121
  ```
64
122
 
65
- ### purge
123
+ #### purge
66
124
  This command remove the specified branches locally and remotely.
67
125
  A confirmation is asked before removal.
68
126
 
69
127
  ```
70
- purge --repo=~/temp/top_20 --branches=release/in_the_ghetto
128
+ purge --repo=/temp/top_20 --branches=release/in_the_ghetto
129
+ ...
71
130
  ```
72
131
 
73
- ### aggregate
74
- It should be useful to aggregate your branches into a single one in case you want to create a release branch.
132
+ #### aggregate
133
+ This command aggregates all of the specified branches into a single one in case you want to create a release branch.
75
134
  It uses the following naming convention: *release/yyyy_mm_dd*
76
135
  A confirmation is asked before aggregating.
77
136
 
78
137
  ```
79
- aggregate --repo=~/Sites/greatest_hits --branches=~/greatest_hits/.branches
138
+ aggregate --repo=./Sites/greatest_hits --branches=./Sites/greatest_hits
80
139
  ```
@@ -22,7 +22,7 @@ module GitCommands
22
22
  parser.parse!(@args)
23
23
  command = @command_klass.new(repo: @repo, branches: @branches)
24
24
  command.send(@command_name)
25
- rescue StandardError => e
25
+ rescue Command::GitError, AbortError, ArgumentError => e
26
26
  error(e.message)
27
27
  end
28
28
 
@@ -8,7 +8,7 @@ module GitCommands
8
8
  include Prompt
9
9
 
10
10
  class GitError < StandardError; end
11
- class NoBranchesError < StandardError; end
11
+ class NoBranchesError < ArgumentError; end
12
12
  class NoentRepositoryError < ArgumentError; end
13
13
 
14
14
  GITHUB_HOST = "github.com"
@@ -92,6 +92,7 @@ module GitCommands
92
92
  end
93
93
 
94
94
  private def fetch_repo(repo)
95
+ fail NoentRepositoryError, "Please specify a valid GIT repository!" unless repo
95
96
  fail NoentRepositoryError, "'#{repo}' is not a valid GIT repository!" unless valid_repo?(repo)
96
97
  Pathname::new(repo)
97
98
  end
@@ -1,3 +1,3 @@
1
1
  module GitCommands
2
- VERSION = "3.1.6"
2
+ VERSION = "3.1.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.6
4
+ version: 3.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - costajob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-17 00:00:00.000000000 Z
11
+ date: 2016-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler