git-process 0.9.1.pre3 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +0 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +2 -0
- data/README.md +27 -9
- data/bin/git-new-fb +42 -13
- data/bin/git-pull-request +79 -13
- data/bin/git-sync +47 -13
- data/bin/git-to-master +56 -13
- data/git-process.gemspec +1 -1
- data/lib/git-process/{abstract-error-builder.rb → abstract_error_builder.rb} +13 -3
- data/lib/git-process/{git-abstract-merge-error-builder.rb → git_abstract_merge_error_builder.rb} +15 -5
- data/lib/git-process/{git-branch.rb → git_branch.rb} +13 -1
- data/lib/git-process/git_branches.rb +72 -0
- data/lib/git-process/{git-lib.rb → git_lib.rb} +82 -70
- data/lib/git-process/git_merge_error.rb +38 -0
- data/lib/git-process/git_process.rb +124 -0
- data/lib/git-process/git_process_error.rb +18 -0
- data/lib/git-process/git_process_options.rb +101 -0
- data/lib/git-process/git_rebase_error.rb +38 -0
- data/lib/git-process/{git-status.rb → git_status.rb} +13 -1
- data/lib/git-process/{github-client.rb → github_client.rb} +13 -1
- data/lib/git-process/github_pull_request.rb +107 -0
- data/lib/git-process/{github-service.rb → github_service.rb} +39 -21
- data/lib/git-process/new_fb.rb +40 -0
- data/lib/git-process/parked_changes_error.rb +40 -0
- data/lib/git-process/pull_request.rb +61 -0
- data/lib/git-process/rebase_to_master.rb +110 -0
- data/lib/git-process/sync.rb +63 -0
- data/lib/git-process/uncommitted_changes_error.rb +23 -0
- data/lib/git-process/version.rb +19 -9
- data/spec/GitRepoHelper.rb +35 -21
- data/spec/{git-abstract-merge-error-builder_spec.rb → git_abstract_merge_error_builder_spec.rb} +3 -3
- data/spec/{git-lib_spec.rb → git_lib_spec.rb} +79 -16
- data/spec/git_process_spec.rb +36 -0
- data/spec/{git-status_spec.rb → git_status_spec.rb} +28 -29
- data/spec/github_pull_request_spec.rb +91 -0
- data/spec/{github-service_spec.rb → github_service_spec.rb} +1 -1
- data/spec/new_fb_spec.rb +80 -0
- data/spec/rebase_to_master_spec.rb +314 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/sync_spec.rb +149 -0
- metadata +46 -43
- data/lib/git-process/git-branches.rb +0 -53
- data/lib/git-process/git-merge-error.rb +0 -31
- data/lib/git-process/git-new-fb-options.rb +0 -34
- data/lib/git-process/git-process-error.rb +0 -10
- data/lib/git-process/git-process-options.rb +0 -82
- data/lib/git-process/git-process.rb +0 -194
- data/lib/git-process/git-pull-request-options.rb +0 -42
- data/lib/git-process/git-rebase-error.rb +0 -31
- data/lib/git-process/git-sync-options.rb +0 -34
- data/lib/git-process/git-to-master-options.rb +0 -18
- data/lib/git-process/parked-changes-error.rb +0 -32
- data/lib/git-process/pull-request.rb +0 -38
- data/lib/git-process/uncommitted-changes-error.rb +0 -15
- data/spec/git-process_spec.rb +0 -328
- data/spec/pull-request_spec.rb +0 -57
data/CHANGELOG.md
ADDED
File without changes
|
data/Gemfile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
# gem "git", "~> 1.2.5"
|
4
3
|
# gem "rugged" # "git" bindings for libgit2
|
5
4
|
gem "launchy", "~> 2.1.0" # web browser interaction
|
6
5
|
gem "octokit", "~> 1.4.0" # GitHub API
|
7
6
|
gem "json", "~> 1.7.3"
|
7
|
+
gem "trollop", "~> 1.16.2" # CLI options parser
|
8
8
|
gem "highline", "~> 1.6.12" # user CLI interaction
|
9
9
|
gem "termios", "~> 0.9.4" # used by highline to make things a little nicer
|
10
10
|
gem "system_timer", "~> 1.2.4" # Needed by faraday via octokit
|
@@ -17,6 +17,6 @@ end
|
|
17
17
|
|
18
18
|
group :development do
|
19
19
|
gem "rake", "~> 0.9.2"
|
20
|
-
gem "yard", "~> 0.8.2.1"
|
20
|
+
gem "yard", "~> 0.8.2.1" # documentation generator
|
21
21
|
gem "redcarpet", "~> 2.1.1"
|
22
22
|
end
|
data/Gemfile.lock
CHANGED
@@ -33,6 +33,7 @@ GEM
|
|
33
33
|
rspec-mocks (2.10.1)
|
34
34
|
system_timer (1.2.4)
|
35
35
|
termios (0.9.4)
|
36
|
+
trollop (1.16.2)
|
36
37
|
webmock (1.8.7)
|
37
38
|
addressable (>= 2.2.7)
|
38
39
|
crack (>= 0.1.7)
|
@@ -52,5 +53,6 @@ DEPENDENCIES
|
|
52
53
|
rspec-mocks (~> 2.10.0)
|
53
54
|
system_timer (~> 1.2.4)
|
54
55
|
termios (~> 0.9.4)
|
56
|
+
trollop (~> 1.16.2)
|
55
57
|
webmock (~> 1.8.7)
|
56
58
|
yard (~> 0.8.2.1)
|
data/README.md
CHANGED
@@ -9,6 +9,7 @@ This provides an easy way to work with a sane git workflow process.
|
|
9
9
|
|
10
10
|
$ gem install git-process
|
11
11
|
|
12
|
+
|
12
13
|
# Overview #
|
13
14
|
|
14
15
|
* `git new-fb` - Create a new feature branch based on the integration branch.
|
@@ -31,7 +32,7 @@ _The following assumes that the integration branch is "origin/master"._
|
|
31
32
|
3. When you feel your work is ready for others to look at, do another "`git sync`" to post your
|
32
33
|
changes to the server, and then "`git pull-request`" to ask someone to review your changes.
|
33
34
|
4. If you get the thumbs up from the code-review, use "`git to-master`".
|
34
|
-
* This will merge and push your changes into "`origin/master`"
|
35
|
+
* This will merge and push your changes into "`origin/master`", closing the pull request.
|
35
36
|
5. If you still need to make changes, do so and use "`git sync`" to keep your branch on the
|
36
37
|
server for that feature updated with your work until all issues have been resolved.
|
37
38
|
|
@@ -46,25 +47,28 @@ _The following assumes that the integration branch is "origin/master"._
|
|
46
47
|
3. When you are ready to merge your work into the mainline, "`git to-master`".
|
47
48
|
* This will merge and push your changes into "`origin/master`"
|
48
49
|
|
50
|
+
|
49
51
|
# Notes #
|
50
52
|
|
51
|
-
* It's assumed that you **_never_** do any work directly on "master": everything is done on a
|
53
|
+
* It's assumed that you **_never_** do any work directly on "`master`": everything is done on a
|
52
54
|
feature branch. This is a much safer and more flexible practice, but may seem odd to
|
53
|
-
people used to old VCSs.
|
55
|
+
people used to old VCSs. In addition to being a much better way of working in general,
|
56
|
+
it is also a requirement to take advantage of Pull Request functionality.
|
54
57
|
* After publishing changes to the main integration branch (i.e., "`git to-master`") the
|
55
58
|
old feature branch is removed as part of cleanup. Git is then "parked" on a "`_parking_`"
|
56
59
|
branch until a new feature branch is created. Work is not expected to be done on this
|
57
60
|
branch, but any that is done is brought over to a newly created feature branch (i.e.,
|
58
61
|
"`git new-fb`").
|
62
|
+
* If there is a problem (such as a merge conflict), this will try to resolve such errors
|
63
|
+
for you as much as it can do safely. When it can't do so in an automated way, it will try
|
64
|
+
to tell you the process for doing so manually.
|
59
65
|
* The first time you use a GitHub feature (e.g., "`git pull-request`"), this will ask for your
|
60
66
|
username and password. It does not store them, but instead uses them to get an OAuth2 token,
|
61
67
|
which is stored in "`git config gitProcess.github.authToken`".
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
*
|
66
|
-
* http://git.kernel.org/?p=git/git.git;a=blob;f=contrib/rerere-train.sh;hb=HEAD
|
67
|
-
* https://github.com/b4mboo/git-review
|
68
|
+
* If you want to use a different integration branch other than "`master`", set the
|
69
|
+
"`gitProcess.integrationBranch`" configuration value. (e.g.,
|
70
|
+
"`git config gitProcess.integrationBranch my-integ-branch`")
|
71
|
+
* This tries to respond "intelligently" to the use of 'rerere'.
|
68
72
|
|
69
73
|
|
70
74
|
# Contributing #
|
@@ -78,3 +82,17 @@ _The following assumes that the integration branch is "origin/master"._
|
|
78
82
|
5. Create new Pull Request
|
79
83
|
|
80
84
|
The tests are written for RSpec 2.
|
85
|
+
|
86
|
+
## License ##
|
87
|
+
|
88
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
89
|
+
you may not use this file except in compliance with the License.
|
90
|
+
You may obtain a copy of the License at
|
91
|
+
|
92
|
+
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0 "License Link")
|
93
|
+
|
94
|
+
Unless required by applicable law or agreed to in writing, software
|
95
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
96
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
97
|
+
See the License for the specific language governing permissions and
|
98
|
+
limitations under the License.
|
data/bin/git-new-fb
CHANGED
@@ -1,21 +1,50 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'git-process/git_process_options'
|
4
|
+
require 'git-process/new_fb'
|
5
5
|
|
6
|
-
|
6
|
+
class NewFeatureBranchOptions
|
7
|
+
include GitProc::GitProcessOptions
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
def summary
|
10
|
+
"Create a new feature branch based on the integration branch."
|
11
|
+
end
|
11
12
|
|
12
|
-
options = Git::Process::NewFeatureBranchOptions.new(File.basename(__FILE__), ARGV)
|
13
13
|
|
14
|
-
|
14
|
+
def description
|
15
|
+
<<DESC
|
16
|
+
DESCRIPTION
|
17
|
+
|
18
|
+
This creates the named branch based on the integration branch.
|
19
|
+
|
20
|
+
EXAMPLE
|
21
|
+
|
22
|
+
Assuming that the the integration branch on the server is "master", \
|
23
|
+
typing "git new-fb my_feature" will do roughly the following \
|
24
|
+
for you:
|
25
|
+
$ git checkout my_feature origin/master
|
26
|
+
|
27
|
+
Also, if you are currently on the "_parking_" branch (see "git to-master"), \
|
28
|
+
this will remove that branch.
|
29
|
+
|
30
|
+
DESC
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def usage(filename)
|
35
|
+
"#{filename} [options] branch_name"
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
def empty_argv_ok?
|
40
|
+
false
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
def post_parse(opts, argv)
|
45
|
+
opts[:branch_name] = argv.shift
|
46
|
+
end
|
15
47
|
|
16
|
-
begin
|
17
|
-
gp.new_feature_branch(options.branch_name)
|
18
|
-
rescue Git::Process::GitProcessError => exp
|
19
|
-
puts exp.message
|
20
|
-
exit(-1)
|
21
48
|
end
|
49
|
+
|
50
|
+
GitProc::NewFeatureBranch.new('.', NewFeatureBranchOptions.new.parse_cli(File.basename(__FILE__), ARGV)).run
|
data/bin/git-pull-request
CHANGED
@@ -1,21 +1,87 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'git-process/pull_request'
|
4
|
+
require 'git-process/git_process_options'
|
5
5
|
|
6
|
-
|
6
|
+
class PullRequestOptions
|
7
|
+
include GitProc::GitProcessOptions
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
def summary
|
10
|
+
"Creates a Pull Request for the current branch."
|
11
|
+
end
|
11
12
|
|
12
|
-
options = Git::Process::PullRequestOptions.new(File.basename(__FILE__), ARGV)
|
13
13
|
|
14
|
-
|
14
|
+
def description
|
15
|
+
<<DESC
|
16
|
+
DESCRIPTION
|
17
|
+
|
18
|
+
This creates a Pull Request on the GitHub server associated with the current \
|
19
|
+
branch. For the reasons why Pull Requests are useful for the development process, \
|
20
|
+
see https://help.github.com/articles/using-pull-requests
|
21
|
+
|
22
|
+
The "git pull-request" command is a nice, simplified alternative to using the \
|
23
|
+
web interface.
|
24
|
+
|
25
|
+
EXAMPLE
|
26
|
+
|
27
|
+
You've been developing your killer new feature or bug fix, and you want \
|
28
|
+
someone else to look at it (to do code-review or otherwise provide input). \
|
29
|
+
When you do "git pull-request", it synchronizes the current branch with \
|
30
|
+
the server (effectively executing "git sync") and creates the Pull Request \
|
31
|
+
against the integration branch. (Usually "master", but this can be changed; \
|
32
|
+
see below.)
|
33
|
+
|
34
|
+
The counterpart to this command is "git to-master".
|
35
|
+
|
36
|
+
NOTES
|
37
|
+
|
38
|
+
* It's assumed that you *never* do any work directly on "master":
|
39
|
+
everything is done on a feature branch. In addition to being a much
|
40
|
+
safer and more flexible way of working in general, it is also a
|
41
|
+
requirement to take advantage of Pull Request functionality.
|
42
|
+
* The first time you use a GitHub feature like this, you will be asked
|
43
|
+
for your username and password. This does not store them, but instead
|
44
|
+
uses them to get an OAuth2 token, which is stored in
|
45
|
+
"git config gitProcess.github.authToken".
|
46
|
+
* If you want to use a different integration branch other than "master",
|
47
|
+
set the "gitProcess.integrationBranch" configuration value. (e.g.,
|
48
|
+
"git config gitProcess.integrationBranch my-integ-branch")
|
49
|
+
|
50
|
+
DESC
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
def usage(filename)
|
55
|
+
"Usage: #{filename} [ options ] pull_request_title"
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def empty_argv_ok?
|
60
|
+
false
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
def extend_opts(parser)
|
65
|
+
parser.opt :base_branch, "The branch on the server that you want this \"pulled\" into. "+
|
66
|
+
"Defaults to the integration branch."
|
67
|
+
parser.opt :head_branch, "The branch that you want reviewed before being \"pulled\" "+
|
68
|
+
"into the base branch. Defaults to the current branch."
|
69
|
+
parser.opt :repo_name, "The name of the repository to \"pull\" into. Defaults to "+
|
70
|
+
"the current repository."
|
71
|
+
parser.opt :description, "The description of the Pull Request. Usually includes a "+
|
72
|
+
"nice description of what was changed to make things easier "+
|
73
|
+
"for the reviewer.", :short => :d
|
74
|
+
parser.opt :user, "Your GitHub username. Only needed the first time you connect, "+
|
75
|
+
"and you will be prompted for it if needed."
|
76
|
+
parser.opt :password, "Your GitHub password. Only needed the first time you connect, "+
|
77
|
+
"and you will be prompted for it if needed."
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
def post_parse(opts, argv)
|
82
|
+
opts[:title] = argv.shift
|
83
|
+
end
|
15
84
|
|
16
|
-
begin
|
17
|
-
gp.create(nil, nil, nil, options.title, options.description, :user => options.user, :password => options.password)
|
18
|
-
rescue Git::Process::GitProcessError => exp
|
19
|
-
puts exp.message
|
20
|
-
exit(-1)
|
21
85
|
end
|
86
|
+
|
87
|
+
GitProc::PullRequest.new('.', PullRequestOptions.new.parse_cli(File.basename(__FILE__), ARGV)).run
|
data/bin/git-sync
CHANGED
@@ -1,21 +1,55 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'git-process/git_process_options'
|
4
|
+
require 'git-process/sync'
|
5
5
|
|
6
|
-
|
6
|
+
class SyncOptions
|
7
|
+
include GitProc::GitProcessOptions
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
def summary
|
10
|
+
"Gets the latest changes that have happened on the integration branch, then pushes your changes to a \"private\" branch on the server."
|
11
|
+
end
|
11
12
|
|
12
|
-
options = Git::Process::SyncOptions.new(File.basename(__FILE__), ARGV)
|
13
13
|
|
14
|
-
|
14
|
+
def description
|
15
|
+
<<DESC
|
16
|
+
DESCRIPTION
|
17
|
+
|
18
|
+
This fetches the latest repository from the server, rebases/merges the current branch \
|
19
|
+
against the changes in the integration branch, then pushes the result up to a branch on \
|
20
|
+
the server of the same name.
|
21
|
+
|
22
|
+
If there is a problem, such as a merge conflict, this tries to \
|
23
|
+
resolve it automatically. If it can not do so in an automated way, \
|
24
|
+
if tells you the steps involved for doing so manually.
|
25
|
+
|
26
|
+
EXAMPLE
|
27
|
+
|
28
|
+
Assuming that the current branch is called "interesting_changes" and the integration \
|
29
|
+
branch on the server is "master", typing "git sync" will do roughly the following \
|
30
|
+
for you:
|
31
|
+
$ git fetch -p
|
32
|
+
$ git merge origin/master
|
33
|
+
$ git push origin interesting_changes:interesting_changes
|
34
|
+
|
35
|
+
DESC
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
def extend_opts(parser)
|
40
|
+
parser.opt :rebase, "Rebase instead of merge against the integration branch"
|
41
|
+
parser.opt :merge, "Merge instead of rebase against the integration branch", :short => :none, :default => true
|
42
|
+
parser.opt :force, "Force the push; defaults to true if --rebase is used", :short => :f, :default => false
|
43
|
+
|
44
|
+
parser.conflicts :rebase, :merge
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
def post_parse(opts, argv)
|
49
|
+
opts[:force] = true if opts[:rebase]
|
50
|
+
opts[:merge] = !opts[:rebase]
|
51
|
+
end
|
15
52
|
|
16
|
-
begin
|
17
|
-
gp.sync_with_server(options.rebase, options.force)
|
18
|
-
rescue Git::Process::GitProcessError => exp
|
19
|
-
puts exp.message
|
20
|
-
exit(-1)
|
21
53
|
end
|
54
|
+
|
55
|
+
GitProc::Sync.new('.', SyncOptions.new.parse_cli(File.basename(__FILE__), ARGV)).run
|
data/bin/git-to-master
CHANGED
@@ -1,21 +1,64 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'git-process/git_process_options'
|
4
|
+
require 'git-process/rebase_to_master'
|
5
5
|
|
6
|
-
|
6
|
+
class ToMasterOptions
|
7
|
+
include GitProc::GitProcessOptions
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
def summary
|
10
|
+
"Rebase against the integration branch, then pushes to it."
|
11
|
+
end
|
11
12
|
|
12
|
-
options = Git::Process::ToMasterOptions.new(File.basename(__FILE__), ARGV)
|
13
13
|
|
14
|
-
|
14
|
+
def description
|
15
|
+
<<DESC
|
16
|
+
DESCRIPTION
|
17
|
+
|
18
|
+
This fetches the latest changes from the server, rebases against \
|
19
|
+
the integration branch, pushes to the integration branch, then does \
|
20
|
+
housecleaning.
|
21
|
+
|
22
|
+
If there is a problem, such as a merge conflict, this tries to \
|
23
|
+
resolve it automatically. If it can not do so in an automated way, \
|
24
|
+
if tells you the steps involved for doing so manually.
|
25
|
+
|
26
|
+
"Housecleaning" includes such things as closing any \
|
27
|
+
Pull Request that may exist for the branch, removing the (now obsolete) \
|
28
|
+
local and remote feature branches, and then "parking" on the \
|
29
|
+
special "_parking_" branch.
|
30
|
+
|
31
|
+
Work is not expected to be done on the "parking" branch, but any that is \
|
32
|
+
done is brought over to a newly created feature branch when you do \
|
33
|
+
"git new-fb".
|
34
|
+
|
35
|
+
It's assumed that you *never* do any work directly on "master": \
|
36
|
+
everything is done on a feature branch. In addition to being a much \
|
37
|
+
safer and more flexible way of working in general, it is also a \
|
38
|
+
requirement to take advantage of Pull Request functionality.
|
39
|
+
|
40
|
+
EXAMPLE
|
41
|
+
|
42
|
+
Assuming that the current branch is called "interesting_changes" and the integration \
|
43
|
+
branch on the server is "master", typing "git to-master" will do roughly the following \
|
44
|
+
for you:
|
45
|
+
$ git fetch -p
|
46
|
+
$ git rebase origin/master
|
47
|
+
$ git push origin interesting_changes:master
|
48
|
+
# close pull request
|
49
|
+
$ git co -b _parking_ origin/master
|
50
|
+
$ git branch -d interesting_changes
|
51
|
+
$ git push origin :interesting_changes
|
52
|
+
|
53
|
+
NOTES
|
54
|
+
|
55
|
+
* If you want to use a different integration branch other than "master",
|
56
|
+
set the "gitProcess.integrationBranch" configuration value. (e.g.,
|
57
|
+
"git config gitProcess.integrationBranch my-integ-branch")
|
58
|
+
|
59
|
+
DESC
|
60
|
+
end
|
15
61
|
|
16
|
-
begin
|
17
|
-
gp.rebase_to_master
|
18
|
-
rescue Git::Process::GitProcessError => exp
|
19
|
-
puts exp.message
|
20
|
-
exit(-1)
|
21
62
|
end
|
63
|
+
|
64
|
+
GitProc::RebaseToMaster.new('.', ToMasterOptions.new.parse_cli(File.basename(__FILE__), ARGV)).run
|
data/git-process.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
16
|
gem.name = "git-process"
|
17
17
|
gem.require_paths = ["lib"]
|
18
|
-
gem.version =
|
18
|
+
gem.version = GitProc::Version::STRING
|
19
19
|
gem.platform = Gem::Platform::RUBY
|
20
20
|
gem.required_ruby_version = '>= 1.8.7'
|
21
21
|
end
|
@@ -1,8 +1,18 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
2
|
+
# you may not use this file except in compliance with the License.
|
3
|
+
# You may obtain a copy of the License at
|
4
|
+
#
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.require 'shellwords'
|
12
|
+
|
3
13
|
require 'shellwords'
|
4
14
|
|
5
|
-
module
|
15
|
+
module GitProc
|
6
16
|
|
7
17
|
#
|
8
18
|
# Assumes that there are two attributes defined: error_message, lib
|
data/lib/git-process/{git-abstract-merge-error-builder.rb → git_abstract_merge_error_builder.rb}
RENAMED
@@ -1,15 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
2
|
+
# you may not use this file except in compliance with the License.
|
3
|
+
# You may obtain a copy of the License at
|
4
|
+
#
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.require 'shellwords'
|
12
|
+
|
13
|
+
require 'git-process/abstract_error_builder'
|
4
14
|
require 'shellwords'
|
5
15
|
|
6
|
-
module
|
16
|
+
module GitProc
|
7
17
|
|
8
18
|
#
|
9
19
|
# Assumes that there are three attributes defined: error_message, lib, continue_command
|
10
20
|
#
|
11
21
|
module AbstractMergeErrorBuilder
|
12
|
-
include AbstractErrorBuilder
|
22
|
+
include GitProc::AbstractErrorBuilder
|
13
23
|
|
14
24
|
def resolved_files
|
15
25
|
@resolved_files ||= find_resolved_files
|
@@ -1,4 +1,16 @@
|
|
1
|
-
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
2
|
+
# you may not use this file except in compliance with the License.
|
3
|
+
# You may obtain a copy of the License at
|
4
|
+
#
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.require 'shellwords'
|
12
|
+
|
13
|
+
module GitProc
|
2
14
|
|
3
15
|
class GitBranch
|
4
16
|
include Comparable
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
2
|
+
# you may not use this file except in compliance with the License.
|
3
|
+
# You may obtain a copy of the License at
|
4
|
+
#
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.require 'shellwords'
|
12
|
+
|
13
|
+
require 'set'
|
14
|
+
require 'git-process/git_branch'
|
15
|
+
|
16
|
+
module GitProc
|
17
|
+
|
18
|
+
class GitBranches
|
19
|
+
include Enumerable
|
20
|
+
|
21
|
+
def initialize(lib)
|
22
|
+
@lib = lib
|
23
|
+
branch_lines = lib.branch(nil, :all => true, :no_color => true).split("\n")
|
24
|
+
@items = SortedSet.new
|
25
|
+
branch_lines.each do |bl|
|
26
|
+
@items << GitBranch.new(bl[2..-1], bl[0..0] == '*', lib)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def <<(item)
|
32
|
+
@items << item
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def each(&block)
|
37
|
+
@items.each {|b| block.call(b)}
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
def names
|
42
|
+
@items.map {|b| b.name}
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
def current
|
47
|
+
@items.find {|b| b.current? }
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def parking
|
52
|
+
@items.find {|b| b.name == '_parking_' }
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def include?(branch_name)
|
57
|
+
@items.find {|b| b.name == branch_name} != nil
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
def [](branch_name)
|
62
|
+
branch_name = current.name if branch_name == 'HEAD'
|
63
|
+
br = @items.find {|b| b.name == branch_name}
|
64
|
+
unless br
|
65
|
+
@lib.logger.warn {"Could not find '#{branch_name}' in #{@items.map{|i|i.name}.join(',')}"}
|
66
|
+
end
|
67
|
+
br
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|