git-process 1.1.4 → 2.0.0

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.
Files changed (58) hide show
  1. data/CHANGELOG.md +14 -1
  2. data/LICENSE +193 -22
  3. data/README.md +212 -71
  4. data/man/git-process.1 +371 -0
  5. metadata +52 -140
  6. data/Gemfile +0 -20
  7. data/Gemfile.lock +0 -53
  8. data/Rakefile +0 -16
  9. data/bin/git-new-fb +0 -58
  10. data/bin/git-pull-request +0 -107
  11. data/bin/git-sync +0 -73
  12. data/bin/git-to-master +0 -133
  13. data/git-process.gemspec +0 -25
  14. data/lib/git-process/abstract_error_builder.rb +0 -53
  15. data/lib/git-process/changed_file_helper.rb +0 -115
  16. data/lib/git-process/git_abstract_merge_error_builder.rb +0 -146
  17. data/lib/git-process/git_branch.rb +0 -105
  18. data/lib/git-process/git_branches.rb +0 -73
  19. data/lib/git-process/git_config.rb +0 -153
  20. data/lib/git-process/git_lib.rb +0 -512
  21. data/lib/git-process/git_logger.rb +0 -84
  22. data/lib/git-process/git_merge_error.rb +0 -28
  23. data/lib/git-process/git_process.rb +0 -172
  24. data/lib/git-process/git_process_error.rb +0 -18
  25. data/lib/git-process/git_process_options.rb +0 -99
  26. data/lib/git-process/git_rebase_error.rb +0 -30
  27. data/lib/git-process/git_remote.rb +0 -256
  28. data/lib/git-process/git_status.rb +0 -108
  29. data/lib/git-process/github_configuration.rb +0 -298
  30. data/lib/git-process/github_pull_request.rb +0 -151
  31. data/lib/git-process/new_fb.rb +0 -50
  32. data/lib/git-process/parked_changes_error.rb +0 -41
  33. data/lib/git-process/pull_request.rb +0 -134
  34. data/lib/git-process/pull_request_error.rb +0 -25
  35. data/lib/git-process/rebase_to_master.rb +0 -148
  36. data/lib/git-process/sync.rb +0 -136
  37. data/lib/git-process/uncommitted_changes_error.rb +0 -23
  38. data/lib/git-process/version.rb +0 -22
  39. data/spec/FileHelpers.rb +0 -19
  40. data/spec/GitRepoHelper.rb +0 -123
  41. data/spec/changed_file_helper_spec.rb +0 -127
  42. data/spec/git_abstract_merge_error_builder_spec.rb +0 -126
  43. data/spec/git_branch_spec.rb +0 -123
  44. data/spec/git_config_spec.rb +0 -45
  45. data/spec/git_lib_spec.rb +0 -176
  46. data/spec/git_logger_spec.rb +0 -66
  47. data/spec/git_process_spec.rb +0 -208
  48. data/spec/git_remote_spec.rb +0 -227
  49. data/spec/git_status_spec.rb +0 -122
  50. data/spec/github_configuration_spec.rb +0 -152
  51. data/spec/github_pull_request_spec.rb +0 -96
  52. data/spec/github_test_helper.rb +0 -49
  53. data/spec/new_fb_spec.rb +0 -130
  54. data/spec/pull_request_helper.rb +0 -94
  55. data/spec/pull_request_spec.rb +0 -128
  56. data/spec/rebase_to_master_spec.rb +0 -429
  57. data/spec/spec_helper.rb +0 -21
  58. data/spec/sync_spec.rb +0 -304
data/Gemfile DELETED
@@ -1,20 +0,0 @@
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.2"
13
- gem "yard", "~> 0.8.2.1" # documentation generator
14
- gem "redcarpet", "~> 2.1.1"
15
- end
16
-
17
- group :test do
18
- gem "rspec", "~> 2.12.0"
19
- gem "webmock", "~> 1.8.7" # network mocking
20
- end
data/Gemfile.lock DELETED
@@ -1,53 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- addressable (2.3.4)
5
- crack (0.3.2)
6
- diff-lcs (1.1.3)
7
- faraday (0.8.7)
8
- multipart-post (~> 1.1)
9
- faraday_middleware (0.9.0)
10
- faraday (>= 0.7.4, < 0.9)
11
- hashie (2.0.3)
12
- highline (1.6.13)
13
- json (1.7.7)
14
- multi_json (1.7.2)
15
- multipart-post (1.2.0)
16
- netrc (0.7.7)
17
- octokit (1.24.0)
18
- addressable (~> 2.2)
19
- faraday (~> 0.8)
20
- faraday_middleware (~> 0.9)
21
- hashie (~> 2.0)
22
- multi_json (~> 1.3)
23
- netrc (~> 0.7.7)
24
- rake (0.9.6)
25
- redcarpet (2.1.1)
26
- rspec (2.12.0)
27
- rspec-core (~> 2.12.0)
28
- rspec-expectations (~> 2.12.0)
29
- rspec-mocks (~> 2.12.0)
30
- rspec-core (2.12.2)
31
- rspec-expectations (2.12.1)
32
- diff-lcs (~> 1.1.3)
33
- rspec-mocks (2.12.2)
34
- trollop (1.16.2)
35
- webmock (1.8.11)
36
- addressable (>= 2.2.7)
37
- crack (>= 0.1.7)
38
- yard (0.8.2.1)
39
-
40
- PLATFORMS
41
- ruby
42
-
43
- DEPENDENCIES
44
- addressable (~> 2.3.4)
45
- highline (= 1.6.13)
46
- json (~> 1.7.3)
47
- octokit (~> 1.24)
48
- rake (~> 0.9.2)
49
- redcarpet (~> 2.1.1)
50
- rspec (~> 2.12.0)
51
- trollop (~> 1.16.2)
52
- webmock (~> 1.8.7)
53
- yard (~> 0.8.2.1)
data/Rakefile DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env rake
2
- require 'bundler/gem_tasks'
3
- require 'rspec/core/rake_task'
4
- require 'yard'
5
- require 'yard/rake/yardoc_task'
6
-
7
- desc 'Default: run specs.'
8
- task :default => :spec
9
-
10
- desc "Run specs"
11
- RSpec::Core::RakeTask.new do |t|
12
- t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
13
- end
14
-
15
- desc "Create docs"
16
- YARD::Rake::YardocTask.new
data/bin/git-new-fb DELETED
@@ -1,58 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- #require "rubygems"
4
- #require "bundler/setup"
5
- #$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '../lib')
6
-
7
- require 'git-process/git_process_options'
8
- require 'git-process/new_fb'
9
- require 'git-process/git_lib'
10
- include GitProc
11
-
12
-
13
- class NewFeatureBranchOptions
14
- include GitProcessOptions
15
-
16
- def summary
17
- "Create a new feature branch based on the integration branch."
18
- end
19
-
20
-
21
- def description
22
- <<DESC
23
- DESCRIPTION
24
-
25
- This creates the named branch based on the integration branch.
26
-
27
- EXAMPLE
28
-
29
- Assuming that the the integration branch on the server is "master", \
30
- typing "git new-fb my_feature" will do roughly the following \
31
- for you:
32
- $ git checkout my_feature origin/master
33
-
34
- Also, if you are currently on the "_parking_" branch (see "git to-master"), \
35
- this will remove that branch.
36
-
37
- DESC
38
- end
39
-
40
-
41
- def usage(filename)
42
- "#{filename} [options] branch_name"
43
- end
44
-
45
-
46
- def empty_argv_ok?
47
- false
48
- end
49
-
50
-
51
- def post_parse(opts, argv)
52
- opts[:branch_name] = argv.shift
53
- end
54
-
55
- end
56
-
57
- opts = NewFeatureBranchOptions.new.parse_cli(File.basename(__FILE__), ARGV)
58
- GitProc::NewFeatureBranch.new(GitProc::GitLib.new('.', opts), opts).run
data/bin/git-pull-request DELETED
@@ -1,107 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- #require "rubygems"
4
- #require "bundler/setup"
5
- #$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '../lib')
6
-
7
- require 'git-process/git_lib'
8
- require 'git-process/pull_request'
9
- require 'git-process/git_process_options'
10
- include GitProc
11
-
12
- class PullRequestOptions
13
- include GitProcessOptions
14
-
15
-
16
- def summary
17
- "Creates or gets a Pull Request."
18
- end
19
-
20
-
21
- def description
22
- <<DESC
23
- DESCRIPTION
24
-
25
- This creates or gets a Pull Request on the GitHub server associated with the current \
26
- branch. For the reasons why Pull Requests are useful for the development process, \
27
- see https://help.github.com/articles/using-pull-requests
28
-
29
- The "git pull-request" command is a nice, simplified alternative to using the \
30
- web interface.
31
-
32
- If no name or number is provided, it is assumed that you want to create a new \
33
- pull request with the same name as the current branch.
34
-
35
- If a number is given, or a number with a server preceding it (e.g., "origin/23"), \
36
- then this assumes that the number refers to an existing pull request identified \
37
- by that number. In that case, the branch associated with the HEAD of the pull \
38
- request is checked out.
39
-
40
- EXAMPLE
41
-
42
- You've been developing your killer new feature or bug fix, and you want \
43
- someone else to look at it (to do code-review or otherwise provide input). \
44
- When you do "git pull-request", it synchronizes the current branch with \
45
- the server (effectively executing "git sync") and creates the Pull Request \
46
- against the integration branch. (Usually "master", but this can be changed; \
47
- see below.)
48
-
49
- The counterpart to this command is "git to-master".
50
-
51
- NOTES
52
-
53
- * It's assumed that you *never* do any work directly on "master":
54
- everything is done on a feature branch. In addition to being a much
55
- safer and more flexible way of working in general, it is also a
56
- requirement to take advantage of Pull Request functionality.
57
- * The first time you use a GitHub feature like this, you will be asked
58
- for your username and password. This does not store them, but instead
59
- uses them to get an OAuth2 token, which is stored in
60
- "git config gitProcess.github.authToken".
61
- * If you want to use a different integration branch other than "master",
62
- set the "gitProcess.integrationBranch" configuration value. (e.g.,
63
- "git config gitProcess.integrationBranch my-integ-branch")
64
-
65
- DESC
66
- end
67
-
68
-
69
- def usage(filename)
70
- "Usage: #{filename} [ options ] [pull_request_title | server/pull_request_number | pull_request_number]"
71
- end
72
-
73
-
74
- def extend_opts(parser)
75
- parser.opt :base_branch, "The branch on the server that you want this \"pulled\" into. "+
76
- "Defaults to the integration branch.", :type => :string
77
- parser.opt :head_branch, "The branch that you want reviewed before being \"pulled\" "+
78
- "into the base branch. Defaults to the current branch.", :type => :string
79
- parser.opt :repo_name, "The name of the repository to \"pull\" into. Defaults to "+
80
- "the current repository.", :type => :string
81
- parser.opt :description, "The description of the Pull Request. Usually includes a "+
82
- "nice description of what was changed to make things easier "+
83
- "for the reviewer.", :short => :d, :type => :string
84
- parser.opt :user, "Your GitHub username. Only needed the first time you connect, "+
85
- "and you will be prompted for it if needed.", :type => :string
86
- parser.opt :password, "Your GitHub password. Only needed the first time you connect, "+
87
- "and you will be prompted for it if needed.", :type => :string
88
- end
89
-
90
-
91
- def post_parse(opts, argv)
92
- arg = argv.shift
93
- if /^\d+$/ =~ arg
94
- opts[:prNumber] = arg
95
- elsif /^(.*)\/(\d+)$/ =~ arg
96
- m = /^(.*)\/(\d+)$/.match(arg)
97
- opts[:server] = m[1]
98
- opts[:prNumber] = m[2]
99
- else
100
- opts[:title] = arg
101
- end
102
- end
103
-
104
- end
105
-
106
- opts = PullRequestOptions.new.parse_cli(File.basename(__FILE__), ARGV)
107
- GitProc::PullRequest.new(GitProc::GitLib.new('.', opts), opts).run
data/bin/git-sync DELETED
@@ -1,73 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # require "rubygems"
4
- # require "bundler/setup"
5
- # $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '../lib')
6
-
7
- require 'git-process/git_process_options'
8
- require 'git-process/sync'
9
- require 'git-process/git_lib'
10
-
11
-
12
- class SyncOptions
13
- include GitProc::GitProcessOptions
14
-
15
-
16
- def summary
17
- "Gets the latest changes that have happened on the integration branch, then pushes your changes to a \"private\" branch on the server."
18
- end
19
-
20
-
21
- def description
22
- <<DESC
23
- DESCRIPTION
24
-
25
- This fetches the latest repository from the server, rebases/merges the current branch \
26
- against the changes in the integration branch, then pushes the result up to a branch on \
27
- the server of the same name. (Unless told not to.)
28
-
29
- If there is a problem, such as a merge conflict, this tries to \
30
- resolve it automatically. If it can not do so in an automated way, \
31
- if tells you the steps involved for doing so manually.
32
-
33
- By default the first server name reported by 'git remote' is used as the server/remote name. \
34
- Since most projects only have a single remote (i.e., "origin") this works most of the time. \
35
- But if you have multiple remotes and want to explicitly set it, use the \
36
- 'gitProcess.remoteName' configuration option.
37
-
38
- Setting `gitProcess.defaultRebaseSync` to "true" causes this to default to using rebase instead of merge.
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 sync" will do roughly the following \
44
- for you:
45
- $ git fetch -p
46
- $ git merge origin/master
47
- $ git push origin interesting_changes:interesting_changes
48
-
49
- DESC
50
- end
51
-
52
-
53
- def extend_opts(parser)
54
- parser.opt :rebase, "Rebase instead of merge against the integration branch"
55
- parser.opt :merge, "Merge instead of rebase against the integration branch", :short => :none, :default => true
56
- parser.opt :force, "Force the push; defaults to true if --rebase is used", :short => :f, :default => false
57
- parser.opt :local, "Do not do a push; gets remote changes, but does not update the server", :short => :l, :default => false
58
-
59
- parser.conflicts :rebase, :merge
60
- parser.conflicts :local, :force
61
- end
62
-
63
-
64
- #noinspection RubyUnusedLocalVariable
65
- def post_parse(opts, argv)
66
- opts[:force] = true if opts[:rebase]
67
- opts[:merge] = !opts[:rebase]
68
- end
69
-
70
- end
71
-
72
- opts = SyncOptions.new.parse_cli(File.basename(__FILE__), ARGV)
73
- GitProc::Sync.new(GitProc::GitLib.new('.', opts), opts).run
data/bin/git-to-master DELETED
@@ -1,133 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- #require "rubygems"
4
- #require "bundler/setup"
5
- #$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '../lib')
6
-
7
- require 'git-process/git_process_options'
8
- require 'git-process/rebase_to_master'
9
- require 'git-process/git_lib'
10
-
11
-
12
- class ToMasterOptions
13
- include GitProc::GitProcessOptions
14
-
15
-
16
- def summary
17
- "Rebase against the integration branch, then pushes to it."
18
- end
19
-
20
-
21
- def description
22
- <<DESC
23
- DESCRIPTION
24
-
25
- This fetches the latest changes from the server, rebases against \
26
- the integration branch, pushes to the integration branch, then does \
27
- housecleaning.
28
-
29
- If there is a problem, such as a merge conflict, this tries to \
30
- resolve it automatically (including responding appropriately to
31
- "rerere" merges). If it can not do so in an automated way, \
32
- if tells you the steps involved for doing so manually.
33
-
34
- "Housecleaning" includes such things as closing any \
35
- Pull Request that may exist for the branch, removing the (now obsolete) \
36
- local and remote feature branches, and then "parking" on the \
37
- special "_parking_" branch.
38
-
39
- Work is not expected to be done on the "_parking_" branch, but any that is \
40
- done is brought over to a newly created feature branch when you do \
41
- "git new-fb".
42
-
43
- It's assumed that you *never* do any work directly on "master": \
44
- everything is done on a feature branch. In addition to being a much \
45
- safer and more flexible way of working in general, it is also a \
46
- requirement to take advantage of Pull Request functionality.
47
-
48
- By default the first server name reported by 'git remote' is used as the \
49
- server/remote name. Since most projects only have a single remote (i.e., \
50
- "origin") this works most of the time. But if you have multiple remotes and \
51
- want to explicitly set it, use the 'gitProcess.remoteName' configuration option.
52
-
53
- If a number is given, or a number with a server preceding it (e.g., \
54
- "origin/23"), then this assumes that the number refers to an existing pull \
55
- request identified by that number. In that case, the branch associated with \
56
- the HEAD of the pull request is checked out before doing the rest of the \
57
- "to-master".
58
-
59
- EXAMPLE WITHOUT PULL REQUEST
60
-
61
- Assuming that the current branch is called "interesting_changes" and the \
62
- integration branch on the server is "master", typing "git to-master" will do \
63
- roughly the following for you:
64
- $ git fetch -p
65
- $ git rebase origin/master
66
- $ git push origin interesting_changes:master
67
- # close pull request if one exists
68
- $ git checkout -b _parking_ origin/master
69
- $ git branch -d interesting_changes
70
- $ git push origin --delete interesting_changes
71
-
72
- If you use the --interactive option, then it does an interactive rebase before the first "push".
73
-
74
- If you use the --keep option, then the process stops after the first "push".
75
-
76
-
77
- EXAMPLE WITH PULL REQUEST
78
-
79
- Assuming that the pull request number is 493, its branch name is "interesting_changes" \
80
- and the integration branch on the server is "master", typing "git to-master 493" will \
81
- do roughly the following for you:
82
- $ git fetch -p
83
- # looks up the information for pull-request 493
84
- $ git checkout -b interesting_changes origin/interesting_changes
85
- $ git rebase origin/master
86
- $ git push origin interesting_changes:master
87
- # close pull request
88
- $ git checkout -b _parking_ origin/master
89
- $ git branch -d interesting_changes
90
- $ git push origin --delete interesting_changes
91
-
92
- If you would like the review the changes locally first, use "git pull-request 493"
93
- instead.
94
-
95
- NOTES
96
-
97
- * If you want to use a different integration branch other than "master",
98
- set the "gitProcess.integrationBranch" configuration value. (e.g.,
99
- "git config gitProcess.integrationBranch my-integ-branch")
100
-
101
- DESC
102
- end
103
-
104
- def usage(filename)
105
- "Usage: #{filename} [ options ] [server/pull_request_number | pull_request_number]"
106
- end
107
-
108
-
109
- def extend_opts(parser)
110
- parser.opt :keep, "Don't do any \"cleanup.\" It keeps the current local "+
111
- "and remote branches, and does not close any "+
112
- "outstanding pull requests.", :short => :k, :default => false
113
- parser.opt :interactive, "Do an interactive rebase before pushing to the server.", :short => :i, :default => false
114
- end
115
-
116
-
117
- def post_parse(opts, argv)
118
- arg = argv.shift
119
- if /^\d+$/ =~ arg
120
- opts[:prNumber] = arg
121
- elsif /^(.*)\/(\d+)$/ =~ arg
122
- m = /^(.*)\/(\d+)$/.match(arg)
123
- opts[:server] = m[1]
124
- opts[:prNumber] = m[2]
125
- else
126
- # "normal" to-master
127
- end
128
- end
129
-
130
- end
131
-
132
- opts = ToMasterOptions.new.parse_cli(File.basename(__FILE__), ARGV)
133
- GitProc::RebaseToMaster.new(GitProc::GitLib.new('.', opts), opts).run