git-process-lib 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/CHANGELOG.md +123 -0
  2. data/Gemfile +21 -0
  3. data/Gemfile.lock +57 -0
  4. data/LICENSE +193 -0
  5. data/README.md +342 -0
  6. data/Rakefile +32 -0
  7. data/bin/git-new-fb +39 -0
  8. data/bin/git-pull-request +63 -0
  9. data/bin/git-sync +38 -0
  10. data/bin/git-to-master +44 -0
  11. data/docs/git-new-fb.1.adoc +83 -0
  12. data/docs/git-process.1.adoc +227 -0
  13. data/docs/git-pull-request.1.adoc +166 -0
  14. data/docs/git-sync.1.adoc +120 -0
  15. data/docs/git-to-master.1.adoc +172 -0
  16. data/git-new-fb.gemspec +20 -0
  17. data/git-process-lib.gemspec +25 -0
  18. data/git-process.gemspec +22 -0
  19. data/git-pull-request.gemspec +20 -0
  20. data/git-sync.gemspec +20 -0
  21. data/git-to-master.gemspec +20 -0
  22. data/lib/git-process/abstract_error_builder.rb +53 -0
  23. data/lib/git-process/changed_file_helper.rb +115 -0
  24. data/lib/git-process/git_abstract_merge_error_builder.rb +130 -0
  25. data/lib/git-process/git_branch.rb +105 -0
  26. data/lib/git-process/git_branches.rb +81 -0
  27. data/lib/git-process/git_config.rb +135 -0
  28. data/lib/git-process/git_lib.rb +646 -0
  29. data/lib/git-process/git_logger.rb +84 -0
  30. data/lib/git-process/git_merge_error.rb +28 -0
  31. data/lib/git-process/git_process.rb +159 -0
  32. data/lib/git-process/git_process_error.rb +18 -0
  33. data/lib/git-process/git_process_options.rb +101 -0
  34. data/lib/git-process/git_rebase_error.rb +30 -0
  35. data/lib/git-process/git_remote.rb +222 -0
  36. data/lib/git-process/git_status.rb +108 -0
  37. data/lib/git-process/github_configuration.rb +298 -0
  38. data/lib/git-process/github_pull_request.rb +165 -0
  39. data/lib/git-process/new_fb.rb +49 -0
  40. data/lib/git-process/parked_changes_error.rb +41 -0
  41. data/lib/git-process/pull_request.rb +136 -0
  42. data/lib/git-process/pull_request_error.rb +25 -0
  43. data/lib/git-process/rebase_to_master.rb +148 -0
  44. data/lib/git-process/sync_process.rb +55 -0
  45. data/lib/git-process/syncer.rb +157 -0
  46. data/lib/git-process/uncommitted_changes_error.rb +23 -0
  47. data/lib/git-process/version.rb +22 -0
  48. data/local-build.rb +24 -0
  49. data/spec/FileHelpers.rb +19 -0
  50. data/spec/GitRepoHelper.rb +123 -0
  51. data/spec/changed_file_helper_spec.rb +127 -0
  52. data/spec/git_abstract_merge_error_builder_spec.rb +64 -0
  53. data/spec/git_branch_spec.rb +123 -0
  54. data/spec/git_config_spec.rb +45 -0
  55. data/spec/git_lib_spec.rb +176 -0
  56. data/spec/git_logger_spec.rb +66 -0
  57. data/spec/git_process_spec.rb +208 -0
  58. data/spec/git_remote_spec.rb +227 -0
  59. data/spec/git_status_spec.rb +122 -0
  60. data/spec/github_configuration_spec.rb +152 -0
  61. data/spec/github_pull_request_spec.rb +117 -0
  62. data/spec/github_test_helper.rb +49 -0
  63. data/spec/new_fb_spec.rb +126 -0
  64. data/spec/pull_request_helper.rb +94 -0
  65. data/spec/pull_request_spec.rb +137 -0
  66. data/spec/rebase_to_master_spec.rb +362 -0
  67. data/spec/spec_helper.rb +21 -0
  68. data/spec/sync_spec.rb +1474 -0
  69. metadata +249 -0
data/CHANGELOG.md ADDED
@@ -0,0 +1,123 @@
1
+ # CHANGELOG - 1.2.0 #
2
+
3
+ ### Since 1.1.4 ###
4
+
5
+ * **Changed git-sync to default to rebasing.** ([GH-112](https://github.com/jdigger/git-process/issues/112))
6
+ * git-sync now can take a branch name to check it out for work ([GH-117](https://github.com/jdigger/git-process/issues/117))
7
+ * Change to use the "native" manpage-based help system for `git help`.
8
+ ([GH-113](https://github.com/jdigger/git-process/issues/113))
9
+ * `git new-fb` now defaults to doing a `git fetch` before creating the feature branch if a remote is defined.
10
+ ([GH-118](https://github.com/jdigger/git-process/issues/118))
11
+ * Removed **--interactive** option from git-to-master
12
+ * Updated README and related files.
13
+ * Retries closing a pull request if it gets a 422. ([GH-102](https://github.com/jdigger/git-process/issues/102))
14
+ * Fixed typo in merge error. ([GH-114](https://github.com/jdigger/git-process/issues/114))
15
+
16
+ ### Since 1.1.3 ###
17
+
18
+ * Improved URI handling of repo names. ([GH-108](https://github.com/jdigger/git-process/issues/108))
19
+
20
+ ### Since 1.1.2 ###
21
+
22
+ * Fixed undefined local variable error when asking about removing local integration branch.
23
+
24
+ ### Since 1.1.0 ###
25
+
26
+ * Fixed scoping in "git-sync"
27
+
28
+ ### Since 1.0.8 ###
29
+
30
+ * Adds `git pull-request {repoName}/{branchNumber}` ([GH-92](https://github.com/jdigger/git-process/issues/92))
31
+ * If a number is given to "git-pull-request", or a number with a server preceding it (e.g., "origin/23"), then
32
+ this assumes that the number refers to an existing pull request identified by that number. In that case, the
33
+ branch associated with the HEAD of the pull request is checked out.
34
+ * Adds `git to-master {repoName}/{branchNumber}` ([GH-94](https://github.com/jdigger/git-process/issues/94))
35
+ * If a number is given to "git-to-master", or a number with a server preceding it (e.g., "origin/23"), then
36
+ this assumes that the number refers to an existing pull request identified by that number. In that case, the
37
+ branch associated with the HEAD of the pull request is checked out before doing the rest of the "to-master".
38
+ * `git new-fb` changes to work better with integration branch ([GH-99](https://github.com/jdigger/git-process/issues/99),
39
+ [GH-103](https://github.com/jdigger/git-process/issues/103) and [GH-105](https://github.com/jdigger/git-process/issues/105))
40
+ * Added pull-request URL to `git pull-request` output ([GH-104](https://github.com/jdigger/git-process/issues/104))
41
+ * Shows a cleaned up version of fetch's output. ([GH-85](https://github.com/jdigger/git-process/issues/85))
42
+ * Changed to use HTTPS instead of HTTP by default for GitHub API usage.
43
+ * Implementation details
44
+ * GitProc::PullRequest has #checkout_pull_request to checkout the HEAD branch of a pull request at any "remote"
45
+ that has been configured, setting the upstream to the pull request's BASE branch
46
+ * GitHubService module no longer uses module-level instance variables, which were causing problems with testing
47
+ * GitHub::PullRequest can now ask for a pull request by id
48
+ * Adds ability to set the upstream/tracking on a branch
49
+ * Upgrades to Octokit 1.24 and no longer overrides the Connection class
50
+ ([GH-74](https://github.com/jdigger/git-process/issues/74))
51
+ * Adds module GitHubTestHelper
52
+ * Made GitLib and AbstractMergeErrorBuilder classes instead of modules
53
+ * Extracted GitCofig and GitRemote out of GitLib
54
+ * Changed to use GitLogger as a logging fascade
55
+ * GitProcess now takes a GitLib instead of a directory
56
+ * GitHubService refactoring; includes extracting GitHubService::Configuration and GitHub::CreatePullRequest.
57
+ * Supports RSpec default module for GitRepoHelper. Any RSpec context can declare :git_repo_helper as metadata to get
58
+ standard GitRepoHelper lifecycle support as part of [GH-97](https://github.com/jdigger/git-process/issues/97).
59
+ * Refactored GitHubService into GitHubService::Configuration
60
+ * Refatored GitHub::PullRequest
61
+ * Refatored GitLib#branch(..) and GitLib#command(..)
62
+
63
+ ### Since 1.0.7 ###
64
+
65
+ * Fixed bug in git_status. [GH-93](https://github.com/jdigger/git-process/issues/93)
66
+
67
+ ### Since 1.0.6 ###
68
+
69
+ * Fixed bug caused by CLI conflict on -i. [GH-13](https://github.com/jdigger/git-process/issues/13)
70
+
71
+ ### Since 1.0.5 ###
72
+
73
+ * Adds option to make rebase the default for git-sync. [GH-82](https://github.com/jdigger/git-process/issues/82)
74
+ * git-sync is now "safer" when working with other people on the same branch. [GH-80](https://github.com/jdigger/git-process/issues/80)
75
+ * Interactive rebase is now an option for git-to-master. [GH-13](https://github.com/jdigger/git-process/issues/13)
76
+ * Simplified/improved arguments for git-pull-request [GH-86](https://github.com/jdigger/git-process/issues/86)
77
+ * Adds some more known statuses. [GH-84](https://github.com/jdigger/git-process/issues/84), [GH-88](https://github.com/jdigger/git-process/issues/88)
78
+
79
+ ### Since 1.0.4 ###
80
+
81
+ * Do not try to fetch/push when doing sync if there is not remote. ([GH-70](https://github.com/jdigger/git-process/issues/70))
82
+ * git-sync now merges in upstream changes. ([GH-79](https://github.com/jdigger/git-process/issues/79))
83
+ * Simplified Windows installation instructions. ([GH-76](https://github.com/jdigger/git-process/issues/76),
84
+ [GH-77](https://github.com/jdigger/git-process/issues/77))
85
+
86
+ ### Since 1.0.3 ###
87
+
88
+ * Gets rid of infinite loop in Highline library. ([GH-72](https://github.com/jdigger/git-process/issues/72))
89
+
90
+ ### Since 1.0.2 ###
91
+
92
+ * Removes the last of the gem dependencies that require native code. This makes it fully compatible
93
+ with systems like Windows.
94
+ * Adds an option to explicitly set the remote server name.
95
+
96
+ ### Since 1.0.1 ###
97
+
98
+ * Changes to dependencies to allow this to work on both Ruby 1.8 and 1.9
99
+
100
+ ### Since 0.9.7 ###
101
+
102
+ * Adds --keep option to git-to-master
103
+ * Fixes problem trying to add/remove an empty list of files
104
+ * Documentation updates
105
+
106
+ ### Since 0.9.7 ###
107
+
108
+ * Adds --keep option to git-to-master
109
+ * Fixes problem trying to add/remove an empty list of files
110
+ * Documentation updates
111
+
112
+ ### Since 0.9.6 ###
113
+
114
+ * Cleans up Gem dependencies
115
+
116
+ ### Since 0.9.5 ###
117
+
118
+ * Cleans up some error messages
119
+ * Improved documentation
120
+ * Adds support for spaces and renames in Status
121
+ * No longer complains if it can't find _parking_
122
+ * Prompts to remove the local version of the integration branch
123
+ * Adds help for handling changed files
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ source "http://rubygems.org"
2
+
3
+ group :default do
4
+ gem "octokit", "~> 1.24" # GitHub API
5
+ gem "json", "~> 1.7.3"
6
+ gem "trollop", "~> 1.16.2" # CLI options parser
7
+ gem "highline", "1.6.13" # user CLI interaction. There is a bug in 1.6.14
8
+ gem "addressable", "~> 2.3.4" # URI processing
9
+ end
10
+
11
+ group :development do
12
+ gem "rake", "~> 0.9"
13
+ gem "yard", "~> 0.8" # documentation generator
14
+ gem "redcarpet", "~> 2"
15
+ end
16
+
17
+ group :test do
18
+ gem "rspec", "~> 2"
19
+ gem "webmock", "~> 1" # network mocking
20
+ gem "rugged", "~> 0.18.0.gh.de28323"
21
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,57 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.5)
5
+ crack (0.4.1)
6
+ safe_yaml (~> 0.9.0)
7
+ diff-lcs (1.2.4)
8
+ faraday (0.8.8)
9
+ multipart-post (~> 1.2.0)
10
+ faraday_middleware (0.9.0)
11
+ faraday (>= 0.7.4, < 0.9)
12
+ hashie (2.0.5)
13
+ highline (1.6.13)
14
+ json (1.7.7)
15
+ multi_json (1.7.7)
16
+ multipart-post (1.2.0)
17
+ netrc (0.7.7)
18
+ octokit (1.25.0)
19
+ addressable (~> 2.2)
20
+ faraday (~> 0.8)
21
+ faraday_middleware (~> 0.9)
22
+ hashie (~> 2.0)
23
+ multi_json (~> 1.3)
24
+ netrc (~> 0.7.7)
25
+ rake (0.9.6)
26
+ redcarpet (2.3.0)
27
+ rspec (2.14.1)
28
+ rspec-core (~> 2.14.0)
29
+ rspec-expectations (~> 2.14.0)
30
+ rspec-mocks (~> 2.14.0)
31
+ rspec-core (2.14.4)
32
+ rspec-expectations (2.14.0)
33
+ diff-lcs (>= 1.1.3, < 2.0)
34
+ rspec-mocks (2.14.1)
35
+ rugged (0.18.0.gh.de28323)
36
+ safe_yaml (0.9.4)
37
+ trollop (1.16.2)
38
+ webmock (1.13.0)
39
+ addressable (>= 2.2.7)
40
+ crack (>= 0.3.2)
41
+ yard (0.8.7)
42
+
43
+ PLATFORMS
44
+ ruby
45
+
46
+ DEPENDENCIES
47
+ addressable (~> 2.3.4)
48
+ highline (= 1.6.13)
49
+ json (~> 1.7.3)
50
+ octokit (~> 1.24)
51
+ rake (~> 0.9)
52
+ redcarpet (~> 2)
53
+ rspec (~> 2)
54
+ rugged (~> 0.18.0.gh.de28323)
55
+ trollop (~> 1.16.2)
56
+ webmock (~> 1)
57
+ yard (~> 0.8)
data/LICENSE ADDED
@@ -0,0 +1,193 @@
1
+ Copyright (c) 2012-2013 Jim Moore
2
+
3
+ Apache License
4
+ Version 2.0, January 2004
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction, and
12
+ distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
15
+ owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all other entities
18
+ that control, are controlled by, or are under common control with that entity.
19
+ For the purposes of this definition, "control" means (i) the power, direct or
20
+ indirect, to cause the direction or management of such entity, whether by
21
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
25
+ permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications, including
28
+ but not limited to software source code, documentation source, and configuration
29
+ files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical transformation or
32
+ translation of a Source form, including but not limited to compiled object code,
33
+ generated documentation, and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or Object form, made
36
+ available under the License, as indicated by a copyright notice that is included
37
+ in or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
40
+ is based on (or derived from) the Work and for which the editorial revisions,
41
+ annotations, elaborations, or other modifications represent, as a whole, an
42
+ original work of authorship. For the purposes of this License, Derivative Works
43
+ shall not include works that remain separable from, or merely link (or bind by
44
+ name) to the interfaces of, the Work and Derivative Works thereof.
45
+
46
+ "Contribution" shall mean any work of authorship, including the original version
47
+ of the Work and any modifications or additions to that Work or Derivative Works
48
+ thereof, that is intentionally submitted to Licensor for inclusion in the Work
49
+ by the copyright owner or by an individual or Legal Entity authorized to submit
50
+ on behalf of the copyright owner. For the purposes of this definition,
51
+ "submitted" means any form of electronic, verbal, or written communication sent
52
+ to the Licensor or its representatives, including but not limited to
53
+ communication on electronic mailing lists, source code control systems, and
54
+ issue tracking systems that are managed by, or on behalf of, the Licensor for
55
+ the purpose of discussing and improving the Work, but excluding communication
56
+ that is conspicuously marked or otherwise designated in writing by the copyright
57
+ owner as "Not a Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
60
+ of whom a Contribution has been received by Licensor and subsequently
61
+ incorporated within the Work.
62
+
63
+ 2. Grant of Copyright License.
64
+
65
+ Subject to the terms and conditions of this License, each Contributor hereby
66
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
67
+ irrevocable copyright license to reproduce, prepare Derivative Works of,
68
+ publicly display, publicly perform, sublicense, and distribute the Work and such
69
+ Derivative Works in Source or Object form.
70
+
71
+ 3. Grant of Patent License.
72
+
73
+ Subject to the terms and conditions of this License, each Contributor hereby
74
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
75
+ irrevocable (except as stated in this section) patent license to make, have
76
+ made, use, offer to sell, sell, import, and otherwise transfer the Work, where
77
+ such license applies only to those patent claims licensable by such Contributor
78
+ that are necessarily infringed by their Contribution(s) alone or by combination
79
+ of their Contribution(s) with the Work to which such Contribution(s) was
80
+ submitted. If You institute patent litigation against any entity (including a
81
+ cross-claim or counterclaim in a lawsuit) alleging that the Work or a
82
+ Contribution incorporated within the Work constitutes direct or contributory
83
+ patent infringement, then any patent licenses granted to You under this License
84
+ for that Work shall terminate as of the date such litigation is filed.
85
+
86
+ 4. Redistribution.
87
+
88
+ You may reproduce and distribute copies of the Work or Derivative Works thereof
89
+ in any medium, with or without modifications, and in Source or Object form,
90
+ provided that You meet the following conditions:
91
+
92
+ You must give any other recipients of the Work or Derivative Works a copy of
93
+ this License; and
94
+ You must cause any modified files to carry prominent notices stating that You
95
+ changed the files; and
96
+ You must retain, in the Source form of any Derivative Works that You distribute,
97
+ all copyright, patent, trademark, and attribution notices from the Source form
98
+ of the Work, excluding those notices that do not pertain to any part of the
99
+ Derivative Works; and
100
+ If the Work includes a "NOTICE" text file as part of its distribution, then any
101
+ Derivative Works that You distribute must include a readable copy of the
102
+ attribution notices contained within such NOTICE file, excluding those notices
103
+ that do not pertain to any part of the Derivative Works, in at least one of the
104
+ following places: within a NOTICE text file distributed as part of the
105
+ Derivative Works; within the Source form or documentation, if provided along
106
+ with the Derivative Works; or, within a display generated by the Derivative
107
+ Works, if and wherever such third-party notices normally appear. The contents of
108
+ the NOTICE file are for informational purposes only and do not modify the
109
+ License. You may add Your own attribution notices within Derivative Works that
110
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
111
+ provided that such additional attribution notices cannot be construed as
112
+ modifying the License.
113
+ You may add Your own copyright statement to Your modifications and may provide
114
+ additional or different license terms and conditions for use, reproduction, or
115
+ distribution of Your modifications, or for any such Derivative Works as a whole,
116
+ provided Your use, reproduction, and distribution of the Work otherwise complies
117
+ with the conditions stated in this License.
118
+
119
+ 5. Submission of Contributions.
120
+
121
+ Unless You explicitly state otherwise, any Contribution intentionally submitted
122
+ for inclusion in the Work by You to the Licensor shall be under the terms and
123
+ conditions of this License, without any additional terms or conditions.
124
+ Notwithstanding the above, nothing herein shall supersede or modify the terms of
125
+ any separate license agreement you may have executed with Licensor regarding
126
+ such Contributions.
127
+
128
+ 6. Trademarks.
129
+
130
+ This License does not grant permission to use the trade names, trademarks,
131
+ service marks, or product names of the Licensor, except as required for
132
+ reasonable and customary use in describing the origin of the Work and
133
+ reproducing the content of the NOTICE file.
134
+
135
+ 7. Disclaimer of Warranty.
136
+
137
+ Unless required by applicable law or agreed to in writing, Licensor provides the
138
+ Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
139
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
140
+ including, without limitation, any warranties or conditions of TITLE,
141
+ NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
142
+ solely responsible for determining the appropriateness of using or
143
+ redistributing the Work and assume any risks associated with Your exercise of
144
+ permissions under this License.
145
+
146
+ 8. Limitation of Liability.
147
+
148
+ In no event and under no legal theory, whether in tort (including negligence),
149
+ contract, or otherwise, unless required by applicable law (such as deliberate
150
+ and grossly negligent acts) or agreed to in writing, shall any Contributor be
151
+ liable to You for damages, including any direct, indirect, special, incidental,
152
+ or consequential damages of any character arising as a result of this License or
153
+ out of the use or inability to use the Work (including but not limited to
154
+ damages for loss of goodwill, work stoppage, computer failure or malfunction, or
155
+ any and all other commercial damages or losses), even if such Contributor has
156
+ been advised of the possibility of such damages.
157
+
158
+ 9. Accepting Warranty or Additional Liability.
159
+
160
+ While redistributing the Work or Derivative Works thereof, You may choose to
161
+ offer, and charge a fee for, acceptance of support, warranty, indemnity, or
162
+ other liability obligations and/or rights consistent with this License. However,
163
+ in accepting such obligations, You may act only on Your own behalf and on Your
164
+ sole responsibility, not on behalf of any other Contributor, and only if You
165
+ agree to indemnify, defend, and hold each Contributor harmless for any liability
166
+ incurred by, or claims asserted against, such Contributor by reason of your
167
+ accepting any such warranty or additional liability.
168
+
169
+ END OF TERMS AND CONDITIONS
170
+
171
+ APPENDIX: How to apply the Apache License to your work
172
+
173
+ To apply the Apache License to your work, attach the following boilerplate
174
+ notice, with the fields enclosed by brackets "{}" replaced with your own
175
+ identifying information. (Don't include the brackets!) The text should be
176
+ enclosed in the appropriate comment syntax for the file format. We also
177
+ recommend that a file or class name and description of purpose be included on
178
+ the same "printed page" as the copyright notice for easier identification within
179
+ third-party archives.
180
+
181
+ Copyright {yyyy} {name of copyright owner}
182
+
183
+ Licensed under the Apache License, Version 2.0 (the "License");
184
+ you may not use this file except in compliance with the License.
185
+ You may obtain a copy of the License at
186
+
187
+ http://www.apache.org/licenses/LICENSE-2.0
188
+
189
+ Unless required by applicable law or agreed to in writing, software
190
+ distributed under the License is distributed on an "AS IS" BASIS,
191
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
192
+ See the License for the specific language governing permissions and
193
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,342 @@
1
+ [![Build Status](https://travis-ci.org/jdigger/git-process.png?branch=master)](https://travis-ci.org/jdigger/git-process)
2
+
3
+ # Purpose #
4
+
5
+ This provides an easy way to work with a sane git workflow process that encourages using highly-focused branches to encourage collaboration, enable fearless changes, and improve team communication.
6
+
7
+ See the F.A.Q. for a much more complete explanation for the thoughts and assumptions that motivates this project.
8
+
9
+
10
+ # Installation #
11
+
12
+ ## Unix-based OS (OSX, Linux, etc.) Installation ##
13
+
14
+ If you are using a Ruby sandboxing system like [RVM](https://rvm.io/) or [rbenv](https://github.com/sstephenson/rbenv)
15
+ (either or which I would recommend) then simply do:
16
+
17
+ $ gem install git-process
18
+
19
+ If you are not using RVM or rbenv, you will likely need to precede that with "`sudo`".
20
+
21
+ Some older operating systems (such as OSX 10.6) are using an old version of RubyGems, which can cause installation problems. Do "`gem update --system`" to fix.
22
+
23
+ ## Windows Installation ##
24
+
25
+ 1. Install Ruby (if you have not done so already) from http://rubyinstaller.org/
26
+ * If it complains about not being able to compile native code, install [DevKit](http://rubyinstaller.org/downloads).
27
+ * See [this StackOverflow](http://stackoverflow.com/questions/8100891/the-json-native-gem-requires-installed-build-tools/8463500#8463500) for help.
28
+ 2. Open a command prompt and type `gem install git-process`
29
+ 3. *THERE IS A KNOWN PROBLEM WITH [HELP ON WINDOWS](https://github.com/jdigger/git-process/issues/120).*
30
+
31
+ ## All Operating Systems ##
32
+
33
+ To get full `git help` and manpage support, do:
34
+
35
+ $ git config --global man.gem-man.cmd "gem man -s"
36
+ $ git config --global man.viewer gem-man
37
+ $ alias man="gem man -s"
38
+
39
+
40
+ # Overview #
41
+
42
+ ## Anticipated Use Cases ##
43
+
44
+ 1. User creates new local branch for focused work.
45
+ 1. User pushes local branch to remote (as feature branch) by merging/rebasing with the integration branch, then pushing to the branch to remote.
46
+ 1. User closes local branch by rebasing integration branch first, then pushing local to integration.
47
+ 1. User initiates GitHub "pull request" to ease collaboration.
48
+
49
+ ## Command List ##
50
+
51
+ * `git new-fb` - Create a new feature branch based on the integration branch.
52
+ * `git sync` - Gets the latest changes that have happened on the integration branch and remote feature branch, then pushes your changes to a feature branch on the server.
53
+ * `git pull-request` - Create or get a Pull Request for the current branch.
54
+ * `git to-master` - Rebase against the integration branch, then pushes to it. Knows how to deal "intelligently" with pull-requests.
55
+
56
+ **All commands are well documented within themselves: Use the "git help" to see the full documentation.** (e.g., "`git help sync`")
57
+
58
+
59
+ ## Configurables ##
60
+
61
+ (See Notes for more details)
62
+
63
+ * `gitProcess.integrationBranch` : The name of the integration branch. Defaults to `master`, but can be set to `develop` or other.
64
+ * `gitProcess.keepLocalIntegrationBranch` : Controls asking about removing the local integration branch. Defaults to 'false' (i.e., do not assume the branch should be there).
65
+ * `gitProcess.remoteName` : Explicitly sets the remote server name to use.
66
+ * `gitProcess.defaultRebaseSync`: Should `git sync` default to using rebase instead of merge? Defaults to 'true' (i.e., Sync using rebase.)
67
+
68
+
69
+ # Assumptions #
70
+
71
+ * You should **_never_** do any work directly on "`master`" (or whatever you define the mainline branch as): everything is done on a feature branch. This is a much safer and more flexible practice than doing everything on the same branch, but may seem odd to people used to old VCSs. In addition to being a much better way of working in general (see the F.A.Q. for more information), it is also a requirement to take advantage of Pull Request functionality.
72
+ * When working on a branch, you should be integrating with "`master`" as often as possible.
73
+ * "`git sync`" makes it extremely easy for you to get any changes that are made in "`master`" into your branch so you can react to it immediately.
74
+ * "`git to-master`" then makes it easy to cleanly integrate the changes you have made. If you need to keep the current branch open, use the `--keep` option. Otherwise it closes the branch along with various other house-keeping duties.
75
+ * The process that you use should be essentially the same, regardless of whether you are working alone, or on a large distributed team.
76
+ * The exception here is "`git pull-request`" since you typically do not use pull requests when working solo or when pair-programming.
77
+
78
+
79
+ # Notes #
80
+
81
+ * After publishing changes to the main integration branch (i.e., "`git to-master`") the old feature branch is removed as part of cleanup. Git is then "parked" on a "`_parking_`" branch until a new feature branch is created. Work is not expected to be done on this branch, but any that is done is brought over to a newly created feature branch (i.e., "`git new-fb`").
82
+ * If there is a problem (such as a merge conflict), this will try to resolve such errors for you as much as it can do safely. When it can't do so in an automated way, it will try to tell you the process for doing so manually.
83
+ * The first time you use a GitHub feature (e.g., "`git pull-request`"), this will ask for your username and password. It does not store them, but instead uses them to get an OAuth2 token, which is stored in "`git config gitProcess.github.authToken`".
84
+ * If you want to use a different integration branch other than "`master`", set the "`gitProcess.integrationBranch`" configuration value. (e.g., "`git config gitProcess.integrationBranch my-integ-branch`")
85
+ * By default the first server name reported by `git remote` is used as the server/remote name. Since most projects only have a single remote (i.e., "origin") this works most of the time. But if you have multiple remotes and want to explicitly set it, use the `gitProcess.remoteName` configuration option.
86
+ * `git pull-request` shows the URL for the pull request after creating it on the server. Most terminal programs let you click on it to open it in your browser. (e.g., Cmd-Click on OSX.)
87
+
88
+
89
+ # Workflow Examples #
90
+
91
+ ## Working Alone On A Local-Only Project ##
92
+
93
+ Jim is working on "my_project" and needs to start work on a new feature.
94
+
95
+ ```
96
+ [a_branch]$ git new-fb save_the_planet
97
+ Creating save_tp off of master
98
+ [save_the_planet]$
99
+ ```
100
+
101
+ He does lots of work. Checkin, checkin, checkin.
102
+
103
+ A sudden new brilliant idea happens.
104
+
105
+ ```
106
+ [save_the_planet]$ git new-fb shave_the_bunnies
107
+ Creating shave_the_bunnies off of master
108
+ [shave_the_bunnies]$
109
+ ```
110
+
111
+ After creating a Sheering class and tests, he commits his changes.
112
+
113
+ ```
114
+ [shave_the_bunnies]$ git commit
115
+ [shave_the_bunnies]$ git to-master
116
+ Rebasing shave_the_bunnies against master
117
+ Removing branch 'shave_the_bunnies'
118
+ [_parking_]$
119
+ ```
120
+
121
+ Time to get back to work on "save_the_planet".
122
+
123
+ ```
124
+ [_parking_]$ git checkout save_the_planet
125
+ [save_the_planet]$ git sync
126
+ Rebasing save_the_planet against master
127
+ [save_the_planet]$
128
+ ```
129
+
130
+ Do more work. Commit. Commit. Commit.
131
+
132
+ ```
133
+ [save_the_planet]$ git sync
134
+ Rebasing save_the_planet against master
135
+ [save_the_planet]$
136
+ ```
137
+
138
+ Liking to have a clean history, he squashes and edits the commits to hide
139
+ the evidence of false starts and stupid ideas so that anyone who sees the
140
+ code in the future will think he was simply a genius.
141
+
142
+ ```
143
+ [save_the_planet]$ git rebase -i
144
+ Rebasing save_the_planet against master
145
+ [save_the_planet]$ git to-master
146
+ Rebasing save_the_planet against master
147
+ Removing branch 'save_the_planet'
148
+ [_parking_]$
149
+ ```
150
+
151
+ Time to release to a grateful world.
152
+
153
+
154
+ ## Working With A Team ##
155
+
156
+ John, Alice, Bill and Sally are working on "big_monies." Alice and John are pairing and
157
+ need to start work on a new feature.
158
+
159
+ ```
160
+ john-[a_branch]$ git new-fb steal_underpants
161
+ Fetching the latest changes from the server
162
+ Creating steal_underpants off of origin/master
163
+ john-[steal_underpants]$
164
+ ```
165
+
166
+ They do lots of work. Checkin, checkin, checkin. It has a lot of steps...
167
+
168
+ Meanwhile Bill has been working on his great idea:
169
+
170
+ ```
171
+ bill-[some_branch]$ git new-fb awesomo4000
172
+ Fetching the latest changes from the server
173
+ Creating awesomo4000 off of origin/master
174
+ bill-[awesomo4000]$
175
+ ```
176
+
177
+ He creates his "Laaaaame" class and checks it in, with a pull request asking Sally to do a code review.
178
+
179
+ ```
180
+ bill-[awesomo4000]$ git commit
181
+ bill-[awesomo4000]$ git pull-request "A.W.E.S.O.M-0 4000 prototype" \
182
+ -d "@sally, can you make sure Butters won't recognize it?"
183
+ Pushing to 'awesomo4000' on 'origin'.
184
+ Creating a pull request asking for 'awesomo4000' to be merged into 'master' on big_monies.
185
+ Created pull request at https://github.com/big_monies/pull/3454
186
+ bill-[awesomo4000]$
187
+ ```
188
+
189
+ Sally sees the email. After looking at it in the web interface, she wants to test it.
190
+
191
+ ```
192
+ sally-[other_branch]$ git pull-request 3454
193
+ Getting #pr_number
194
+ Fetching the latest changes from the server
195
+ new branch: awesomo4000
196
+ Setting upstream/tracking for branch 'awesomo4000' to 'origin/master'.
197
+ sally-[awesomo4000]$ git sync
198
+ Fetching the latest changes from the server
199
+ Rebasing awesomo4000 against origin/master
200
+ Pushing to 'awesomo4000' on 'origin'.
201
+ sally-[awesomo4000]$
202
+ ```
203
+
204
+ After verifying that the tests still work and "it's all good" she promotes the code to integration.
205
+
206
+ ```
207
+ sally-[awesomo4000]$ git to-master
208
+ Fetching the latest changes from the server
209
+ Rebasing awesomo4000 against origin/master
210
+ Pushing to 'awesomo4000' on 'origin'.
211
+ Removing branch remote 'awesomo4000'
212
+ Removing branch local 'awesomo4000'
213
+ Closing a pull request #3454 on origin.
214
+ sally-[_parking_]$
215
+ ```
216
+
217
+ Over lunch Alice gets a brainstorm ("a duck and rubber hose!") and rushes off to her computer:
218
+
219
+ ```
220
+ alice-[lens_cap]$ git sync steal_underpants
221
+ Fetching the latest changes from the server
222
+ Creating steal_underpants off of origin/steal_underpants
223
+ Setting upstream/tracking for branch 'steal_underpants' to 'origin/master'.
224
+ alice-[steal_underpants]$
225
+ ```
226
+
227
+ She makes her changes, syncs back up with the server, and heads over to pair with John again.
228
+
229
+ ```
230
+ alice-[steal_underpants]$ git commit
231
+ alice-[steal_underpants]$ git sync
232
+ Fetching the latest changes from the server
233
+ Rebasing steal_underpants against origin/master
234
+ Pushing to 'steal_underpants' on 'origin'.
235
+ alice-[steal_underpants]$
236
+ ```
237
+
238
+ John, meanwhile, had made some changes of his own.
239
+
240
+ ```
241
+ john-[steal_underpants]$ git commit
242
+ john-[steal_underpants]$ git sync
243
+ Fetching the latest changes from the server
244
+ Remote branch has changed
245
+ Rebasing steal_underpants against origin/steal_underpants
246
+ Rebasing steal_underpants against origin/master
247
+ Pushing to 'steal_underpants' on 'origin'.
248
+ john-[steal_underpants]$
249
+ ```
250
+
251
+ At this point, his local branch has Alice's change as well as Bill and
252
+ Sally's A.W.E.S.O.M-O 4000 enhancements.
253
+
254
+ After confirming with Alice and Bill that everything looks good, he
255
+ pushes his changes up for integration.
256
+
257
+ ```
258
+ john-[steal_underpants]$ git to-master
259
+ Fetching the latest changes from the server
260
+ Rebasing steal_underpants against origin/master
261
+ Pushing to 'steal_underpants' on 'origin'.
262
+ Removing remote branch 'steal_underpants'
263
+ Removing local branch 'steal_underpants'
264
+ [_parking_]$
265
+ ```
266
+
267
+ Profit!!
268
+
269
+
270
+ # F.A.Q. #
271
+
272
+ ## Q: How is this different from git-flow or GitHub flow? ##
273
+
274
+ ["git-flow"](http://nvie.com/posts/a-successful-git-branching-model/) is designed around having a very strongly defined process around keeping new development, hotfixes, release process changes, etc. all clearly separated. The problem I have with it is that it's too much "process" for not enough gain. (It has a waterfall feel to it, very much against the more modern [Continuous Delivery](http://continuousdelivery.com/) approach.)
275
+
276
+ ["GitHub Flow"](http://scottchacon.com/2011/08/31/github-flow.html) is a lot cleaner, but relies too heavily (IMHO) on web-based tools and on merging instead of rebasing. It is also focussed very tightly on a Continuous Deployment process, which is great for them, but not practical for everyone.
277
+
278
+
279
+ ## Q: Wait, I heard "branches are evil." Why should I do something evil? ##
280
+
281
+ Branches are extremely powerful tools that allow for clean organization/modularization of development.
282
+
283
+ * Branches make it easy to sandbox changes while they are in a state of flux, while at the same time allowing you to be very fearless about making potentially breaking changes.
284
+ * For example, I commit "green to green": Doing [TDD](http://en.wikipedia.org/wiki/Test-driven_development), I commit every time I have a newly passing test case. So, assuming I'm in a regular development flow, I'm committing my changes every five minutes or so. Tiny commits, but lots of them. What that means is that if I make a "less than wise choice" at some point, it's trivial to rewind to before I'd made the mistake, potentially keep the throw-away code in another branch while I do my cleanup, and generally use the full power of a revision control system to make my life safer and easier. The branch(es) are pretty chaotic, but that's not a problem because before integrating with the mainline, I take a moment to cleanup: Squash related commits together, write clearer commit messages (since now I know what "the answer" is), and generally move from my drafts to a more finished result. (See below on objections related to "lying with rebase.") That may just be me, though, because I'm very paranoid when it comes to computers. I tend to automatically hit Cmd/Ctl-S every time I type a period when I'm writing, or when I close a block when I'm programming. I have a minimum of three copies/backups around the world of all my important documents. And I "`git sync`" frequently to make sure my machine isn't the only place where all my hard work is being stored. Have I mentioned I don't trust computers?
285
+
286
+ * Branches allow for focused collaboration. Because a branch is about exactly one thing, it means that a team can collaborate around a feature/bug (especially when used in conjunction with a "pull request"), and keep such changes sandboxed until such time that they are ready to bring a larger audience into the mix.
287
+ * Branches encourage being less "shy" about your code. I have heard, on a number of occasions, developers say "I'm not ready to push this to the server yet because \[it's still rough (and embarrassing)]/\[it may break other people]/etc." All of those reasons for "hoarding" code are moot with branches.
288
+
289
+ Jez Humble, a brilliant Principle at ThoughtWorks Studios, talks a lot about how "branches are evil." Unfortunately, people hear that, know how smart he is, and simply repeat it without really understanding what his objections are. Fortunately, he [posted clarification about what's really meant by that](http://continuousdelivery.com/2011/07/on-dvcs-continuous-integration-and-feature-branches/). He essentially says that the problem is that developers abuse branches by not merging with mainline (i.e., "master") on a regular basis. Not constantly getting changes *from* mainline makes life rough when it comes time to integrate. Not putting your changes *into* mainline means that your changes are not being validated (via [Continuous Integration](http://martinfowler.com/articles/continuousIntegration.html), or -- better -- with [Continuous Delivery](http://continuousdelivery.com/)). Both are, in fact, sins akin to not doing automated testing.
290
+
291
+ Making it "easier to do things right than wrong" (i.e., using branches and keeping them synced with mainline) was the primary motivation for this project. Every command here is focussed on making it trivial to use branches that stay in sync with mainline and encourage collaboration.
292
+
293
+
294
+ ## Q: Why so much emphasis on rebasing? Isn't rebasing a dangerous lie? ##
295
+
296
+ Like any powerful tool, "`git rebase`" is "dangerous" if used incorrectly, just like "`rm`"/"`del`". You simply need to know when and how to use it safely. And in the world of version control systems, "rebasing" is easily one of the most _**useful**_ tools to come around since the "`commit`" command.
297
+
298
+ [A famous article](http://paul.stadig.name/2010/12/thou-shalt-not-lie-git-rebase-ammend.html) that people have been parroting in various forms for a while makes the case that rebasing (and its various forms, such as squashing, amending commits, etc.) is a "lie." As with so many things, context is everything.
299
+
300
+ You almost certainly should *not* rebase things that you have "published." Generally this really means "Don't rebase the 'master' branch!" Fortunately, these scripts make it impossible to rebase the mainline by accident.
301
+
302
+ Rebasing "your" code is an extremely useful way of communicating clearly. In the "green to green" scenario above about branches, a lot of noise is generated. If someone wants to review my code, or cherry-pick in my changes, it's too much of a mess to effectively do so. Also, as part of the process of squashing, I have the opportunity to write clearer commit message based upon my newly enhanced understanding. The intermediate commits were my "drafts" and I'm now submitting my cleaned up copy.
303
+
304
+ If you have ever seen an "active" project that uses a process like "git-flow" that encourages a lot of branching and merging, you've seen how hard it can be to follow a particular line of development. Branch lines are flying around everywhere, and half the commits are pretty much pure noise. (e.g., "Merge branch 'master' of ... into master".) It's also hard to follow the order in which commits actually impacted the mainline. In many ways, in practice merges turn into "a truth effectively being a lie" (because it's buried in the noise) versus rebases that are "a lie (changed from it's 'original' form) to tell an effective truth" (clean and very clear about its impact).
305
+
306
+ One significant advantage of using automation like this is that it lets you have the best of both worlds. For example, "`git sync`" uses "rebase" instead of "merge" in a way to is completely safe for collaboration on the same branch. As long as the other people are also using "`git sync`", it will make sure that changes are automatically incorporated with and brought in line. (See the extensive test suite in "`sync_spec.rb`" if you want to see how this works.)
307
+
308
+ This project is trying to promote clear communication about reality as it applies to the code, over micro-management over no-longer-relevant history. Thus rational for the judicious use of rebase.
309
+
310
+
311
+ # Contributing #
312
+
313
+ ## Coding Setup ##
314
+
315
+ 1. Fork it
316
+ 2. Create your feature branch (`git checkout -b my-new-feature origin/master`)
317
+ 3. Commit your changes (`git commit`)
318
+ 4. Push to the branch (`git push origin my-new-feature`)
319
+ 5. Create new Pull Request
320
+
321
+ or, if using these scripts:
322
+
323
+ 1. Fork it
324
+ 2. `git new-fb my-new-feature
325
+ 3. `git commit`
326
+ 4. `git sync`
327
+ 5. `git pull-request`
328
+
329
+
330
+ ## License ##
331
+
332
+ Licensed under the Apache License, Version 2.0 (the "License");
333
+ you may not use this file except in compliance with the License.
334
+ You may obtain a copy of the License at
335
+
336
+ [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0 "License Link")
337
+
338
+ Unless required by applicable law or agreed to in writing, software
339
+ distributed under the License is distributed on an "AS IS" BASIS,
340
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
341
+ See the License for the specific language governing permissions and
342
+ limitations under the License.