gitx 2.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +28 -0
  3. data/.rspec +2 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +6 -0
  6. data/CONTRIBUTING.md +67 -0
  7. data/Gemfile +4 -0
  8. data/Guardfile +8 -0
  9. data/LICENSE.txt +22 -0
  10. data/README.md +87 -0
  11. data/Rakefile +5 -0
  12. data/bin/git-buildtag +6 -0
  13. data/bin/git-cleanup +7 -0
  14. data/bin/git-integrate +6 -0
  15. data/bin/git-nuke +6 -0
  16. data/bin/git-release +6 -0
  17. data/bin/git-review +6 -0
  18. data/bin/git-share +6 -0
  19. data/bin/git-start +6 -0
  20. data/bin/git-track +6 -0
  21. data/bin/git-update +6 -0
  22. data/gitx.gemspec +37 -0
  23. data/lib/gitx.rb +8 -0
  24. data/lib/gitx/cli/base_command.rb +56 -0
  25. data/lib/gitx/cli/buildtag_command.rb +39 -0
  26. data/lib/gitx/cli/cleanup_command.rb +45 -0
  27. data/lib/gitx/cli/integrate_command.rb +94 -0
  28. data/lib/gitx/cli/nuke_command.rb +62 -0
  29. data/lib/gitx/cli/release_command.rb +40 -0
  30. data/lib/gitx/cli/review_command.rb +93 -0
  31. data/lib/gitx/cli/share_command.rb +15 -0
  32. data/lib/gitx/cli/start_command.rb +37 -0
  33. data/lib/gitx/cli/track_command.rb +14 -0
  34. data/lib/gitx/cli/update_command.rb +35 -0
  35. data/lib/gitx/configuration.rb +44 -0
  36. data/lib/gitx/extensions/string.rb +12 -0
  37. data/lib/gitx/extensions/thor.rb +39 -0
  38. data/lib/gitx/github.rb +178 -0
  39. data/lib/gitx/version.rb +3 -0
  40. data/spec/fixtures/vcr_cassettes/pull_request_does_exist_with_failure_status.yml +135 -0
  41. data/spec/fixtures/vcr_cassettes/pull_request_does_exist_with_success_status.yml +149 -0
  42. data/spec/fixtures/vcr_cassettes/pull_request_does_not_exist.yml +133 -0
  43. data/spec/gitx/cli/base_command_spec.rb +41 -0
  44. data/spec/gitx/cli/buildtag_command_spec.rb +70 -0
  45. data/spec/gitx/cli/cleanup_command_spec.rb +37 -0
  46. data/spec/gitx/cli/integrate_command_spec.rb +290 -0
  47. data/spec/gitx/cli/nuke_command_spec.rb +165 -0
  48. data/spec/gitx/cli/release_command_spec.rb +172 -0
  49. data/spec/gitx/cli/review_command_spec.rb +356 -0
  50. data/spec/gitx/cli/share_command_spec.rb +32 -0
  51. data/spec/gitx/cli/start_command_spec.rb +96 -0
  52. data/spec/gitx/cli/track_command_spec.rb +31 -0
  53. data/spec/gitx/cli/update_command_spec.rb +79 -0
  54. data/spec/spec_helper.rb +86 -0
  55. data/spec/support/global_config.rb +26 -0
  56. data/spec/support/home_env.rb +11 -0
  57. data/spec/support/matchers/meet_expectations_matcher.rb +7 -0
  58. data/spec/support/pry.rb +1 -0
  59. data/spec/support/stub_execution.rb +14 -0
  60. data/spec/support/timecop.rb +9 -0
  61. data/spec/support/vcr.rb +6 -0
  62. data/spec/support/webmock.rb +1 -0
  63. metadata +348 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ae23c0140c764302c1c7cc84a1f05344f50f4459
4
+ data.tar.gz: fde7992a4535128773c335cf41ee88dc84de6487
5
+ SHA512:
6
+ metadata.gz: 2d77a7dd2291a7978410485d2dd2c470892aa65bd4be6688678f2b539b23024acd2975250e5a11595d28ab7e77a62efa9b885b182207c0a1494de896e645f653
7
+ data.tar.gz: 7fbde0cd2c143ce9230e5a8d0f898b342e213562469a1ea50ed25b1f077dee461b91de67e96258a0465108e65e24c20a4785958b69bebc8b659085daacd3f2cd
@@ -0,0 +1,28 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## GIT
17
+ *.orig
18
+
19
+ ## PROJECT::GENERAL
20
+ coverage
21
+ rdoc
22
+ pkg
23
+
24
+ ## bundler
25
+ Gemfile.lock
26
+
27
+ ## RSpec temp files
28
+ spec/tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1 @@
1
+ 2.1.2
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - '2.1.2'
4
+ before_install:
5
+ - git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
6
+ - git fetch
@@ -0,0 +1,67 @@
1
+ # Development Workflow
2
+
3
+ ## Resources
4
+ * [Git Workflow Presentation](https://docs.google.com/presentation/d/1euOiki_e4OQ4jymGhS-o3xcET8-KZhDONUolDlOVT30/edit?usp=sharing)
5
+ * [git extensions gem](https://github.com/wireframe/gitx)
6
+
7
+ ## Step 1: Create feature branch...
8
+
9
+ ```bash
10
+ $ git start my-feature-branch
11
+ ```
12
+
13
+ * The `start` command ensures your branch name is valid and your codebase is uptodate.
14
+ * Use a descriptive branch name to help other developers (ex: fix-login-screen, api-refactor, payment-reconcile, etc)
15
+
16
+ ## Step 2: Implement the requested change...
17
+ Use [Test Driven Development](http://en.wikipedia.org/wiki/Test-driven_development) to ensure that the feature has proper code coverage.
18
+
19
+ * **RED** - Write tests for the desired behavior...
20
+ * **GREEN** - Write just enough code to get the tests to pass...
21
+ * **REFACTOR** - Cleanup for clarity and DRY-ness...
22
+
23
+
24
+ ### Development Protips™
25
+ * Follow [best practices](http://robots.thoughtbot.com/post/48933156625/5-useful-tips-for-a-better-commit-message) for git commit messages to communicate your changes.
26
+ * Add [ticket references to commits to automatically trigger product management workflows](http://help.sprint.ly/knowledgebase/articles/108139-available-scm-vcs-commands)
27
+ * Only write the **minimal** amount of code necessary to accomplish the given task.
28
+ * Ensure branch stays up-to-date with latest changes that are merged into master by using: `$ git update`
29
+ * Changes that are not directly related to the current feature should be cherry-picked into their own branch and merged separately.
30
+
31
+ ### Testing Protips™
32
+ * Every line of code should have associated unit tests. If it's not tested, it's probably broken and you just don't know it yet...
33
+ * Use [BetterSpecs.org](http://betterspecs.org/) as reference for writing readable and maintainable unit tests.
34
+
35
+
36
+ ## Step 3: Peer Review (aka Pull Request)...
37
+
38
+ ```
39
+ $ git review
40
+ ```
41
+
42
+ * Describe high level overview of the branch in pull request description. Include links to relevant resources.
43
+ * Record **artifacts** created by this feature (ex: screenshots of UI changes, screencasts of UX changes, logs from database migrations, etc)
44
+ * Document **follow-up** items/tasks that need to be addressed post-release
45
+
46
+ ### Questions to ask...
47
+ * Is there a simpler way to accomplish the task at hand?
48
+ * Are we solving the problems of today and not over engineering for the problems of tomorrow?
49
+
50
+ ## Step 4: QA
51
+
52
+ > With great power comes great responsibility…
53
+
54
+ * You are responsible to test your changes locally and in production environments as necessary
55
+ * Test changes in local development environment using the same process used by Continuous Integration with: `$ rake ci`
56
+ * Smoketest all changes locally and in staging environment when appropriate with: `$ git integrate staging`
57
+
58
+ ## Step 5: Sign-off and release
59
+
60
+ ```
61
+ $ git release
62
+ ```
63
+
64
+ * Ensure that build is green before releasing branch
65
+ * Pull requests must be signed off by team leads before release (preferrably via :shipit: emoji)
66
+
67
+ ## Step 5: Profit?
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in your gemspec file
4
+ gemspec
@@ -0,0 +1,8 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :rspec, cmd: 'bundle exec rspec', failed_mode: :keep do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { 'spec' }
8
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Ryan Sonnek
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,87 @@
1
+ [![Build Status](https://travis-ci.org/wireframe/gitx.png?branch=master)](https://travis-ci.org/wireframe/gitx)
2
+ [![Code Coverage](https://coveralls.io/repos/wireframe/gitx/badge.png)](https://coveralls.io/r/wireframe/gitx)
3
+ [![Code Climate](https://codeclimate.com/github/wireframe/gitx.png)](https://codeclimate.com/github/wireframe/gitx)
4
+
5
+ # GitX
6
+
7
+ > Useful Git eXtensions for improved development workflows
8
+
9
+ ### Global Options
10
+ * `--trace` or `-v` = verbose output for debugging commands
11
+ * `--pretend` or `-p` = dry run commands and do not actually invoke operations
12
+
13
+ ## git start <new_branch_name (optional)>
14
+
15
+ update local repository with latest upstream changes and create a new feature branch
16
+
17
+ ## git update
18
+
19
+ update the local feature branch with latest remote changes plus upstream released changes.
20
+
21
+ ## git integrate <aggregate_branch_name (optional, default: staging)>
22
+
23
+ integrate the current feature branch into an aggregate branch (ex: prototype, staging)
24
+
25
+ ## git review <feature_branch_name (optional, default: current_branch)>
26
+
27
+ create a pull request on github for peer review of the current branch. This command is re-runnable
28
+ in order to re-assign pull requests.
29
+
30
+ options:
31
+ * `--assign` or `-a` = assign pull request to github user
32
+ * `--open` or `-o` = open pull request in default web browser.
33
+ * `--bump` or `-b` = bump an existing pull request by posting a comment to re-review new changes
34
+ * `--approve` = approve/signoff on pull request (with optional feedback)
35
+ * `--reject` = reject pull request (with details)
36
+
37
+ NOTE: the `--bump` option will also update the pull request commit status to mark the branch as 'pending peer review'.
38
+ This setting is cleared when a reviewer approves or rejects the pull request.
39
+
40
+ ## git release <feature_branch_name (optional, default: current_branch)
41
+
42
+ release the feature branch to master. This operation will perform the following:
43
+
44
+ * pull latest code from remote feature branch
45
+ * pull latest code from master branch
46
+ * prompt user to confirm they actually want to perform the release
47
+ * check if pull request commit status is currently successful
48
+ * merge current branch into master
49
+ * (optional) cleanup merged branches from remote server
50
+
51
+ options:
52
+ * `--cleanup` = automatically cleanup merged branches after release complete
53
+
54
+ # Extra Utility Git Extensions
55
+
56
+ ## git cleanup
57
+
58
+ delete released branches after they have been merged into master.
59
+
60
+ ## git nuke <aggregate_branch_name>
61
+
62
+ reset an aggregate branch (ex: prototype, staging) back to a known good state.
63
+
64
+ ## git buildtag
65
+
66
+ create a build tag for the current Travis-CI build and push it back to origin
67
+
68
+
69
+ ## Contributing
70
+ See [CONTRIBUTING.md](CONTRIBUTING.md)
71
+
72
+ * Fork the project.
73
+ * Make your feature addition or bug fix.
74
+ * Add tests for it. This is important so I don't break it in a
75
+ future version unintentionally.
76
+ * Commit, do not mess with rakefile, version, or history.
77
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
78
+ * Send me a pull request. Bonus points for topic branches.
79
+
80
+ ## Related Projects
81
+ * [socialcast-git-extensions](https://github.com/socialcast/socialcast-git-extensions)
82
+ * [thegarage-gitx](https://github.com/thegarage/thegarage-gitx)
83
+
84
+
85
+ ## Copyright
86
+ See [LICENSE.txt](LICENSE.txt)
87
+
@@ -0,0 +1,5 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new('spec')
5
+ task :default => :spec
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+ require 'gitx/cli/buildtag_command'
5
+ args = ARGV.dup.unshift('buildtag')
6
+ Gitx::Cli::BuildtagCommand.start(args)
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+ require 'gitx/cli/cleanup_command'
5
+ args = ARGV.dup.unshift('cleanup')
6
+ Gitx::Cli::CleanupCommand.start(args)
7
+
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+ require 'gitx/cli/integrate_command'
5
+ args = ARGV.dup.unshift('integrate')
6
+ Gitx::Cli::IntegrateCommand.start(args)
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+ require 'gitx/cli/nuke_command'
5
+ args = ARGV.dup.unshift('nuke')
6
+ Gitx::Cli::NukeCommand.start(args)
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+ require 'gitx/cli/release_command'
5
+ args = ARGV.dup.unshift('release')
6
+ Gitx::Cli::ReleaseCommand.start(args)
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+ require 'gitx/cli/review_command'
5
+ args = ARGV.dup.unshift('review')
6
+ Gitx::Cli::ReviewCommand.start(args)
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+ require 'gitx/cli/share_command'
5
+ args = ARGV.dup.unshift('share')
6
+ Gitx::Cli::ShareCommand.start(args)
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+ require 'gitx/cli/start_command'
5
+ args = ARGV.dup.unshift('start')
6
+ Gitx::Cli::StartCommand.start(args)
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+ require 'gitx/cli/track_command'
5
+ args = ARGV.dup.unshift('track')
6
+ Gitx::Cli::TrackCommand.start(args)
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+ require 'gitx/cli/update_command'
5
+ args = ARGV.dup.unshift('update')
6
+ Gitx::Cli::UpdateCommand.start(args)
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gitx/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'gitx'
8
+ spec.version = Gitx::VERSION
9
+ spec.authors = ['Ryan Sonnek']
10
+ spec.email = ['ryan.sonnek@gmail.com']
11
+ spec.description = %q{Git eXtensions for improved development workflow}
12
+ spec.summary = %q{Utility scripts for Git to increase productivity for common operations}
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'rugged', '~> 0.21.0'
22
+ spec.add_runtime_dependency 'thor'
23
+ spec.add_runtime_dependency 'octokit'
24
+
25
+ spec.add_development_dependency 'bundler', '~> 1.3'
26
+ spec.add_development_dependency 'rake'
27
+ spec.add_development_dependency 'rspec', '~> 3.0'
28
+ spec.add_development_dependency 'pry', '>= 0'
29
+ spec.add_development_dependency 'webmock', '>= 0'
30
+ spec.add_development_dependency 'timecop', '~> 0.7.0'
31
+ spec.add_development_dependency 'vcr'
32
+ spec.add_development_dependency 'guard'
33
+ spec.add_development_dependency 'guard-rspec'
34
+ spec.add_development_dependency 'coveralls'
35
+ spec.add_development_dependency 'terminal-notifier'
36
+ spec.add_development_dependency 'terminal-notifier-guard'
37
+ end
@@ -0,0 +1,8 @@
1
+ require 'gitx/version'
2
+ require 'gitx/configuration'
3
+ require 'gitx/extensions/string'
4
+ require 'gitx/extensions/thor'
5
+
6
+ module Gitx
7
+ BASE_BRANCH = 'master'
8
+ end
@@ -0,0 +1,56 @@
1
+ require 'thor'
2
+ require 'pathname'
3
+ require 'rugged'
4
+ require 'gitx'
5
+
6
+ module Gitx
7
+ module Cli
8
+ class BaseCommand < Thor
9
+ include Thor::Actions
10
+
11
+ class MergeError < Thor::Error; end
12
+
13
+ add_runtime_options!
14
+
15
+ method_option :trace, :type => :boolean, :aliases => '-v'
16
+ def initialize(*args)
17
+ super(*args)
18
+ end
19
+
20
+ private
21
+
22
+ def repo
23
+ @repo ||= begin
24
+ path = Dir.pwd
25
+ Rugged::Repository.discover(path)
26
+ end
27
+ end
28
+
29
+ def checkout_branch(branch_name)
30
+ run_cmd "git checkout #{branch_name}"
31
+ end
32
+
33
+ # lookup the current branch of the repo
34
+ def current_branch
35
+ repo.branches.find(&:head?)
36
+ end
37
+
38
+ def assert_aggregate_branch!(target_branch)
39
+ fail "Invalid aggregate branch: #{target_branch} must be one of supported aggregate branches #{config.aggregate_branches}" unless config.aggregate_branch?(target_branch)
40
+ end
41
+
42
+ def assert_not_protected_branch!(branch, action)
43
+ raise "Cannot #{action} reserved branch" if config.reserved_branch?(branch) || config.aggregate_branch?(branch)
44
+ end
45
+
46
+ # helper to invoke other CLI commands
47
+ def execute_command(command_class, method, args = [])
48
+ command_class.new.send(method, *args)
49
+ end
50
+
51
+ def config
52
+ @configuration ||= Gitx::Configuration.new(repo.workdir)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,39 @@
1
+ require 'thor'
2
+ require 'gitx'
3
+ require 'gitx/cli/base_command'
4
+
5
+ module Gitx
6
+ module Cli
7
+ class BuildtagCommand < BaseCommand
8
+
9
+ desc 'buildtag', 'create a tag for the current build and push it back to origin (supports Travis CI and Codeship)'
10
+ def buildtag
11
+ fail 'Unknown branch. Environment variables TRAVIS_BRANCH or CI_BRANCH are required' unless branch_name
12
+ fail "Branch must be one of the supported taggable branches: #{config.taggable_branches}" unless config.taggable_branch?(branch_name)
13
+
14
+ label = "buildtag generated by build #{build_number}"
15
+ create_build_tag(branch_name, label)
16
+ end
17
+
18
+ private
19
+
20
+ # pull the current branch name from environment variables
21
+ # supports Travis CI or Codeship variables
22
+ # see https://www.codeship.io/documentation/continuous-integration/set-environment-variables/
23
+ def branch_name
24
+ ENV['TRAVIS_BRANCH'] || ENV['CI_BRANCH']
25
+ end
26
+
27
+ def build_number
28
+ ENV['TRAVIS_BUILD_NUMBER'] || ENV['CI_BUILD_NUMBER']
29
+ end
30
+
31
+ def create_build_tag(branch, label)
32
+ timestamp = Time.now.utc.strftime '%Y-%m-%d-%H-%M-%S'
33
+ git_tag = "build-#{branch}-#{timestamp}"
34
+ run_cmd "git tag #{git_tag} -a -m '#{label}'"
35
+ run_cmd "git push origin #{git_tag}"
36
+ end
37
+ end
38
+ end
39
+ end