rgitflow 0.1.0.pre.alpha.pre.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MmI5ZWZjYzhjYmYwMDljY2Q4M2RlNjgzZTMzMmQyNTNkZWJhMDA2NA==
5
+ data.tar.gz: !binary |-
6
+ ZWQ5OTBhYzQ1MWU2YWVkMTYwNTJhNjY4NjJkZjk4ZjM1ZTRkM2ZjNw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZDEzZmE0NjQwMWNlMzE0YTI3Y2JjMjE2OTQ0ZjFmZTA3Y2I4NzhlZDkyNDI2
10
+ MjFkMzYyMGVjYjEzNjllMGU4ZmZhNGE2NjIyYjAxZDJiN2U2ODMwOWQ4MDQx
11
+ YmFjNWEyOWQ2ODBhZDA0N2ZkNGY2NDRiZTU1OGE2ODBmNzFmODE=
12
+ data.tar.gz: !binary |-
13
+ YTliZmMzMjllNTQwYjRmMDdmMzRkYWE4MjI3YjBjYzdiNWQ2MTkzNWJmYWVk
14
+ OTFhM2RiZGI1MzhjYWEwMDlhMDcxNDdiZjY0YTM1MmRkZjlkZGY5NTRjOGEw
15
+ OWNlYmE2YzE5YjVkZTgyNWYwMWRjMGQ4ZTQ2ZjRhZDAxNWY3NTM=
data/.codeclimate.yml ADDED
@@ -0,0 +1,13 @@
1
+ engines:
2
+ rubocop:
3
+ enabled: true
4
+ bundler-audit:
5
+ enabled: true
6
+ fixme:
7
+ enabled: true
8
+ ratings:
9
+ paths:
10
+ - lib/**
11
+ - "**.rb"
12
+ exclude_paths:
13
+ - spec/**/*
data/.document ADDED
@@ -0,0 +1,3 @@
1
+ -
2
+ ChangeLog.rdoc
3
+ LICENSE.txt
data/.gitignore ADDED
@@ -0,0 +1,143 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ ### Ruby template
12
+ *.gem
13
+ *.rbc
14
+ /.config
15
+ /coverage/
16
+ /InstalledFiles
17
+ /pkg/
18
+ /spec/reports/
19
+ /test/tmp/
20
+ /test/version_tmp/
21
+ /tmp/
22
+
23
+ ## Specific to RubyMotion:
24
+ .dat*
25
+ .repl_history
26
+ build/
27
+
28
+ ## Documentation cache and generated files:
29
+ /.yardoc/
30
+ /_yardoc/
31
+ /doc/
32
+ /rdoc/
33
+
34
+ ## Environment normalisation:
35
+ /.bundle/
36
+ /vendor/bundle
37
+ /lib/bundler/man/
38
+
39
+ # for a library or gem, you might want to ignore these files since the code is
40
+ # intended to run in multiple environments; otherwise, check them in:
41
+ # Gemfile.lock
42
+ # .ruby-version
43
+ # .ruby-gemset
44
+
45
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
46
+ .rvmrc
47
+
48
+ spec/examples.txt
49
+
50
+
51
+ ### JetBrains template
52
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion
53
+
54
+ *.iml
55
+
56
+ ## Directory-based project format:
57
+ .idea/
58
+ # if you remove the above rule, at least ignore the following:
59
+
60
+ # User-specific stuff:
61
+ # .idea/workspace.xml
62
+ # .idea/tasks.xml
63
+ # .idea/dictionaries
64
+
65
+ # Sensitive or high-churn files:
66
+ # .idea/dataSources.ids
67
+ # .idea/dataSources.xml
68
+ # .idea/sqlDataSources.xml
69
+ # .idea/dynamic.xml
70
+ # .idea/uiDesigner.xml
71
+
72
+ # Gradle:
73
+ # .idea/gradle.xml
74
+ # .idea/libraries
75
+
76
+ # Mongo Explorer plugin:
77
+ # .idea/mongoSettings.xml
78
+
79
+ ## File-based project format:
80
+ *.ipr
81
+ *.iws
82
+
83
+ ## Plugin-specific files:
84
+
85
+ # IntelliJ
86
+ /out/
87
+
88
+ # mpeltonen/sbt-idea plugin
89
+ .idea_modules/
90
+
91
+ # JIRA plugin
92
+ atlassian-ide-plugin.xml
93
+
94
+ # Crashlytics plugin (for Android Studio and IntelliJ)
95
+ com_crashlytics_export_strings.xml
96
+ crashlytics.properties
97
+ crashlytics-build.properties
98
+
99
+ ### Objective-C template
100
+ # Xcode
101
+ #
102
+ build/
103
+ *.pbxuser
104
+ !default.pbxuser
105
+ *.mode1v3
106
+ !default.mode1v3
107
+ *.mode2v3
108
+ !default.mode2v3
109
+ *.perspectivev3
110
+ !default.perspectivev3
111
+ xcuserdata
112
+ *.xccheckout
113
+ *.moved-aside
114
+ DerivedData
115
+ *.hmap
116
+ *.ipa
117
+ *.xcuserstate
118
+
119
+ # CocoaPods
120
+ #
121
+ # We recommend against adding the Pods directory to your .gitignore. However
122
+ # you should judge for yourself, the pros and cons are mentioned at:
123
+ # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
124
+ #
125
+ #Pods/
126
+
127
+ ### Xcode template
128
+ build/
129
+ *.pbxuser
130
+ !default.pbxuser
131
+ *.mode1v3
132
+ !default.mode1v3
133
+ *.mode2v3
134
+ !default.mode2v3
135
+ *.perspectivev3
136
+ !default.perspectivev3
137
+ xcuserdata
138
+ *.xccheckout
139
+ *.moved-aside
140
+ DerivedData
141
+ *.xcuserstate
142
+
143
+
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.6
5
+ deploy:
6
+ provider: rubygems
7
+ api_key:
8
+ secure: nQUUd0plPSX2osSS7Z4Y+XefgF7n01jvwTJDcou97RRG4cyUUYo0rkXRHf7pZx8VTPQP+W+pM9HSP4lHFdcaTGWvP4BPRDc2VFEfu0o9eSse6RKoruqlRc1Wc5vAZVskR3lrOm6/zvYjFoPmruTSU3Zeoey54I+VERbThc7foQhCCKVbpoqRQ/XrpCwu5P9bf9yjIuC/f+z0jRZc51xG1e48M2s3Td3zvb4h8f7577CoUe3C+llQywGid7JvwF9XMXc2wdcV/Qr+Y4nsZ6I2LA/cZ/m2C9Z05MSc3/K6dtLJzzeCQoydA4NCgoTsBzNPwMS6KiokLEPpo6ufBY+CsgsyUJWf3rtRRYyJFxwHCBZaAMh00rLxbt5GXx3GvzVH7I6p1wlmFkfd19w5LUJGa1K9g6bMChC9VzWlXknfbk1958h/lex+KJ+SA2qJdDhHh3A4SIdJkdo71F4PSxTHbA4hCaOPxDDZcd02TUJGJUcS/BaNskoydSRYNDQ2WWGpPPp+KoMwIrIyft1A5zmK/JDTvR8kxDgtUPxXslGvVyJG/PrkmsmUobwiDXZuZv/vcW+YpxYS91rUQJJvMjTypNbe45Upgbx4miI1QyI2O0xtvNnH3C0AU1iN/35F6yrIzz37uUvYGZyRssadR3mim1V+sN/D6V1vWlZMJSI6e7E=
9
+ gem: rgitflow
10
+ on:
11
+ all_branches: true
12
+ repo: Nunnery/rgitflow
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup markdown --title "timewizard Documentation" --protected
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/ChangeLog.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ === 0.1.0 / 2015-08-25
2
+
3
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rake-gems.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Richard Harrah
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # RGitFlow
2
+
3
+ A collection of Rake tasks intended to emulate Git Flow in a Ruby context.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'rgitflow'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install rgitflow
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ TODO: Write development instructions here
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Nunnery/rgitflow. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
36
+
data/Rakefile ADDED
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+
5
+ begin
6
+ require 'bundler'
7
+ rescue LoadError => e
8
+ warn e.message
9
+ warn "Run `gem install bundler` to install Bundler."
10
+ exit -1
11
+ end
12
+
13
+ begin
14
+ Bundler.setup(:development)
15
+ rescue Bundler::BundlerError => e
16
+ warn e.message
17
+ warn "Run `bundle install` to install missing gems."
18
+ exit e.status_code
19
+ end
20
+
21
+ require 'rake'
22
+
23
+ require 'rspec/core/rake_task'
24
+ RSpec::Core::RakeTask.new
25
+
26
+ task :test => [:spec]
27
+ task :default => [:spec]
28
+
29
+ require 'yard'
30
+ YARD::Rake::YardocTask.new
31
+ task :doc => [:yard]
32
+
33
+ require 'bundler/gem_tasks'
34
+
35
+ require 'rgitflow'
@@ -0,0 +1,8 @@
1
+ # @private
2
+ def __p(path) File.join(RGitFlow::ROOT, 'rgitflow', *path.split('/')); end
3
+
4
+ module RGitFlow
5
+ autoload :Config, __p('config')
6
+ autoload :Printing, __p('printing')
7
+ autoload :Install, __p('install')
8
+ end
@@ -0,0 +1,42 @@
1
+ module RGitFlow
2
+ class Config
3
+ class << self
4
+ attr_accessor :options
5
+ end
6
+
7
+ CONFIG_DIR = Pathname.pwd
8
+
9
+ CONFIG_FILE = File.expand_path(CONFIG_DIR, '.rgitflow')
10
+
11
+ DEFAULT_OPTIONS = {
12
+ :master => 'master',
13
+ :develop => 'develop',
14
+ :feature => 'feature',
15
+ :hotfix => 'hotfix',
16
+ :release => 'release'
17
+ }
18
+
19
+ def self.load
20
+ self.options = SymbolHash.new false
21
+ options.update DEFAULT_OPTIONS
22
+ options.update read_config_file
23
+ end
24
+
25
+ def self.save
26
+ require 'yaml'
27
+ Dir.mkdir(CONFIG_DIR) unless File.directory?(CONFIG_DIR)
28
+ File.open(CONFIG_FILE, 'w') {|f| f.write(YAML.dump(options)) }
29
+ end
30
+
31
+ def self.read_config_file
32
+ if File.file?(CONFIG_FILE)
33
+ require 'yaml'
34
+ YAML.load_file(CONFIG_FILE)
35
+ else
36
+ {}
37
+ end
38
+ end
39
+ end
40
+
41
+ Config.options = Config::DEFAULT_OPTIONS
42
+ end
@@ -0,0 +1,5 @@
1
+ class Object
2
+ def blank?
3
+ respond_to?(:empty?) ? empty? : !self
4
+ end
5
+ end
@@ -0,0 +1,75 @@
1
+ # ORIGINALLY PART OF YARD
2
+ #
3
+ # A subclass of Hash where all keys are converted into Symbols, and
4
+ # optionally, all String values are converted into Symbols.
5
+ class SymbolHash < Hash
6
+ # Creates a new SymbolHash object
7
+ #
8
+ # @param [Boolean] symbolize_value converts any String values into Symbols
9
+ # if this is set to +true+.
10
+ def initialize(symbolize_value = true)
11
+ @symbolize_value = symbolize_value
12
+ end
13
+
14
+ # @overload [](hash)
15
+ # Creates a SymbolHash object from an existing Hash
16
+ #
17
+ # @example
18
+ # SymbolHash['x' => 1, :y => 2] # => #<SymbolHash:0x...>
19
+ # @param [Hash] hash the hash object
20
+ # @return [SymbolHash] a new SymbolHash from a hash object
21
+ #
22
+ # @overload [](*list)
23
+ # Creates a SymbolHash from an even list of keys and values
24
+ #
25
+ # @example
26
+ # SymbolHash[key1, value1, key2, value2, ...]
27
+ # @param [Array] list an even list of key followed by value
28
+ # @return [SymbolHash] a new SymbolHash object
29
+ def self.[](*hsh)
30
+ obj = new
31
+ if hsh.size == 1 && hsh.first.is_a?(Hash)
32
+ hsh.first.each {|k,v| obj[k] = v }
33
+ else
34
+ 0.step(hsh.size, 2) {|n| obj[hsh[n]] = hsh[n+1] }
35
+ end
36
+ obj
37
+ end
38
+
39
+ # Assigns a value to a symbolized key
40
+ # @param [#to_sym] key the key
41
+ # @param [Object] value the value to be assigned. If this is a String and
42
+ # values are set to be symbolized, it will be converted into a Symbol.
43
+ def []=(key, value)
44
+ super(key.to_sym, value.instance_of?(String) && @symbolize_value ? value.to_sym : value)
45
+ end
46
+
47
+ # Accessed a symbolized key
48
+ # @param [#to_sym] key the key to access
49
+ # @return [Object] the value associated with the key
50
+ def [](key) super(key.to_sym) end
51
+
52
+ # Deleted a key and value associated with it
53
+ # @param [#to_sym] key the key to delete
54
+ # @return [void]
55
+ def delete(key) super(key.to_sym) end
56
+
57
+ # Tests if a symbolized key exists
58
+ # @param [#to_sym] key the key to test
59
+ # @return [Boolean] whether the key exists
60
+ def has_key?(key) super(key.to_sym) end
61
+
62
+ # Updates the object with the contents of another Hash object.
63
+ # This method modifies the original SymbolHash object
64
+ #
65
+ # @param [Hash] hash the hash object to copy the values from
66
+ # @return [SymbolHash] self
67
+ def update(hash) hash.each {|k,v| self[k] = v }; self end
68
+ alias_method :merge!, :update
69
+
70
+ # Merges the contents of another hash into a new SymbolHash object
71
+ #
72
+ # @param [Hash] hash the hash of objects to copy
73
+ # @return [SymbolHash] a new SymbolHash containing the merged data
74
+ def merge(hash) dup.merge!(hash) end
75
+ end
@@ -0,0 +1,9 @@
1
+ require 'git/base'
2
+
3
+ Git::Base.class_eval do
4
+ def dirty?
5
+ puts '0 files changed, 0 insertions(+), 0 deletions(-)'
6
+ puts diff.diff_shortstat.to_s.strip
7
+ '0 files changed, 0 insertions(+), 0 deletions(-)' != diff.diff_shortstat.to_s.strip
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ require 'git/diff'
2
+
3
+ Git::Diff.class_eval do
4
+
5
+ def diff_shortstat
6
+ unless @cached_shortstat
7
+ @cached_shortstat = @base.lib.diff_shortstat(@from, @to, {:path_limiter => @path})
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,25 @@
1
+ require 'git/lib'
2
+
3
+ Git::Lib.class_eval do
4
+ def push(remote, branch = 'master', opts = {})
5
+ # Small hack to keep backwards compatibility with the 'push(remote, branch, tags)' method signature.
6
+ opts = {:tags => opts} if [true, false].include?(opts)
7
+
8
+ arr_opts = []
9
+ arr_opts << '--force' if opts[:force] || opts[:f]
10
+ arr_opts << '--delete' if opts[:delete] || opts[:d]
11
+ arr_opts << remote
12
+
13
+ command('push', arr_opts + [branch])
14
+ command('push', ['--tags'] + arr_opts) if opts[:tags]
15
+ end
16
+
17
+ def diff_shortstat(obj1 = 'HEAD', obj2 = nil, opts = {})
18
+ diff_opts = ['--shortstat']
19
+ diff_opts << obj1
20
+ diff_opts << obj2 if obj2.is_a?(String)
21
+ diff_opts << '--' << opts[:path_limiter] if opts[:path_limiter].is_a? String
22
+
23
+ command('diff', diff_opts)
24
+ end
25
+ end
@@ -0,0 +1,31 @@
1
+ require 'rgitflow/printing'
2
+ require 'git'
3
+
4
+ module RGitFlow
5
+ class Install
6
+ include RGitFlow::Printing
7
+
8
+ class << self
9
+ attr_accessor :instance
10
+
11
+ def install_tasks(opts = {})
12
+ new(opts[:dir]).install
13
+ end
14
+ end
15
+
16
+ attr_reader :dir, :git
17
+
18
+ def initialize(dir = nil)
19
+ @dir = dir || Pathname.pwd
20
+ @git = Git.open @dir
21
+ end
22
+
23
+ def install
24
+ require 'rgitflow/tasks/scm/status'
25
+ RGitFlow::Tasks::SCM::Status.new @git
26
+
27
+ require 'rgitflow/tasks/feature/tasks'
28
+ RGitFlow::Tasks::Feature.install_tasks({:git => @git})
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,76 @@
1
+ require 'ansi/constants'
2
+
3
+ module RGitFlow
4
+ # Contains logic for printing messages to the console. Supports ANSI colors.
5
+ # Inspired by rubygems-tasks' printing.rb
6
+ module Printing
7
+ # String to prepend to any status messages
8
+ # @return [String] prefix for status messages
9
+ STATUS_PREFIX = if $stdout.tty?
10
+ "#{ANSI::Constants::GREEN}#{ANSI::Constants::BRIGHT}>>>#{ANSI::Constants::CLEAR}"
11
+ else
12
+ '>>>'
13
+ end
14
+
15
+ # String to prepend to any debug messages
16
+ # @return [String] prefix for debug messages
17
+ DEBUG_PREFIX = if $stderr.tty?
18
+ "#{ANSI::Constants::YELLOW}#{ANSI::Constants::BRIGHT}>>>#{ANSI::Constants::CLEAR}"
19
+ else
20
+ '>>>'
21
+ end
22
+
23
+ # String to prepend to any error messages
24
+ # @return [String] prefix for error messages
25
+ ERROR_PREFIX = if $stderr.tty?
26
+ "#{ANSI::Constants::RED}#{ANSI::Constants::BRIGHT}>>>#{ANSI::Constants::CLEAR}"
27
+ else
28
+ '>>>'
29
+ end
30
+
31
+ INPUT_PREFIX = if $stderr.tty?
32
+ "#{ANSI::Constants::BLUE}#{ANSI::Constants::BRIGHT}<<<#{ANSI::Constants::CLEAR}"
33
+ else
34
+ '<<<'
35
+ end
36
+
37
+ protected
38
+
39
+ # Prints a status message to the console
40
+ # @param [String] message message to print to the console
41
+ # @return [void]
42
+ def status(message = '')
43
+ if Rake.verbose
44
+ STDOUT.puts "#{STATUS_PREFIX} #{message}"
45
+ end
46
+ nil
47
+ end
48
+
49
+ # Prints a debug message to the console
50
+ # @param [String] message message to print to the console
51
+ # @return [void]
52
+ def debug(message = '')
53
+ if Rake.verbose
54
+ STDERR.puts "#{DEBUG_PREFIX} #{message}"
55
+ end
56
+ nil
57
+ end
58
+
59
+ # Prints an error message to the console
60
+ # @param [String] message message to print to the console
61
+ # @return [void]
62
+ def error(message = '')
63
+ STDERR.puts "#{ERROR_PREFIX} #{message}"
64
+ nil
65
+ end
66
+
67
+ # Prints a prompt message to the console
68
+ # @param [String] message message to print to the console
69
+ # @return [void]
70
+ def prompt(message = '')
71
+ status message
72
+ STDOUT.print "#{INPUT_PREFIX} "
73
+ nil
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,36 @@
1
+ require 'rgitflow/tasks/task'
2
+
3
+ module RGitFlow
4
+ module Tasks
5
+ class Feature
6
+ class Finish < RGitFlow::Tasks::Task
7
+ def initialize(git)
8
+ super(git, 'finish', 'Finish a feature branch', ['rgitflow', 'feature'])
9
+ end
10
+
11
+ protected
12
+
13
+ def run
14
+ status 'Finishing feature branch...'
15
+
16
+ branch = @git.current_branch
17
+
18
+ unless branch.start_with? RGitFlow::Config.options[:feature]
19
+ error 'Cannot finish a feature branch unless you are in a feature branch'
20
+ abort
21
+ end
22
+
23
+ @git.branch(RGitFlow::Config.options[:develop]).checkout
24
+ @git.merge branch
25
+
26
+ @git.push
27
+ @git.push('origin', branch, {:delete => true})
28
+
29
+ @git.branch(branch).delete
30
+
31
+ status "Finished feature branch #{branch}!"
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,44 @@
1
+ require 'rgitflow/tasks/task'
2
+
3
+ module RGitFlow
4
+ module Tasks
5
+ class Feature
6
+ class Start < RGitFlow::Tasks::Task
7
+ def initialize(git)
8
+ super(git, 'start', 'Start a feature branch', ['rgitflow', 'feature'])
9
+ end
10
+
11
+ protected
12
+
13
+ def run
14
+ status 'Starting feature branch...'
15
+
16
+ branch = ENV['BRANCH']
17
+
18
+ while branch.blank?
19
+ error 'Cannot create a branch with an empty name!'
20
+ prompt 'Please enter a name for your feature branch:'
21
+ branch = STDIN.gets.chomp
22
+ end
23
+
24
+ branch = [RGitFlow::Config.options[:feature], branch].join('/')
25
+
26
+ if @git.is_local_branch? branch
27
+ error 'Cannot create a branch that already exists locally'
28
+ abort
29
+ end
30
+
31
+ if @git.is_remote_branch? branch
32
+ error 'Cannot create a branch that already exists remotely'
33
+ abort
34
+ end
35
+
36
+ @git.branch(branch).create
37
+ @git.branch(branch).checkout
38
+
39
+ status "Started feature branch #{branch}!"
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,27 @@
1
+ module RGitFlow
2
+ module Tasks
3
+ class Feature
4
+ autoload :Start, 'rgitflow/tasks/feature/start'
5
+ autoload :Finish, 'rgitflow/tasks/feature/finish'
6
+
7
+ class << self
8
+ attr_accessor :instance
9
+
10
+ def install_tasks(opts = {})
11
+ new(opts[:git]).install
12
+ end
13
+ end
14
+
15
+ attr_reader :git
16
+
17
+ def initialize(git = nil)
18
+ @git = git || Git.open(Pathname.pwd)
19
+ end
20
+
21
+ def install
22
+ Start.new @git
23
+ Finish.new @git
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,56 @@
1
+ require 'rgitflow/tasks/task'
2
+
3
+ module RGitFlow
4
+ module Tasks
5
+ module SCM
6
+ class Status < RGitFlow::Tasks::Task
7
+ def initialize(git)
8
+ super(git, 'status', 'Check the status of the repository', ['rgitflow', 'scm'])
9
+ end
10
+
11
+ protected
12
+
13
+ def run
14
+ if dirty?
15
+ error 'There are uncommitted changes in the repository!'
16
+
17
+ print_status
18
+
19
+ abort
20
+ else
21
+ status 'There are no uncommitted changes in the repository.'
22
+ end
23
+ end
24
+
25
+ def dirty?
26
+ @git.dirty?
27
+ end
28
+
29
+ def print_status
30
+ added = []
31
+ modified = []
32
+ deleted = []
33
+
34
+ @git.diff.each { |f|
35
+ if f.type == 'new'
36
+ added << f
37
+ elsif f.type == 'modified'
38
+ modified << f
39
+ elsif f.type == 'deleted'
40
+ deleted << f
41
+ end
42
+ }
43
+
44
+ debug 'added'
45
+ added.each { |f| debug " #{ANSI::Constants::GREEN}#{ANSI::Constants::BRIGHT}#{f.path}#{ANSI::Constants::CLEAR}" }
46
+
47
+ debug 'modified'
48
+ modified.each { |f| debug " #{ANSI::Constants::YELLOW}#{ANSI::Constants::BRIGHT}#{f.path}#{ANSI::Constants::CLEAR}" }
49
+
50
+ debug 'deleted'
51
+ deleted.each { |f| debug " #{ANSI::Constants::RED}#{ANSI::Constants::BRIGHT}#{f.path}#{ANSI::Constants::CLEAR}" }
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,57 @@
1
+ require 'rgitflow/printing'
2
+
3
+ require 'rake'
4
+ require 'rake/tasklib'
5
+
6
+ module RGitFlow
7
+ module Tasks
8
+ class Task < ::Rake::TaskLib
9
+ include RGitFlow::Printing
10
+ # The namespaces of the task
11
+ # @return [Array<String>] the task namespaces
12
+ attr_accessor :namespaces
13
+
14
+ # The name of the task
15
+ # @return [String] the task name
16
+ attr_accessor :name
17
+
18
+ # The description of the task
19
+ # @return [String] the task description
20
+ attr_accessor :description
21
+
22
+ # Runs a +Proc+ before the task
23
+ # @return [Proc] a proc to call before running the task
24
+ attr_accessor :before
25
+
26
+ # Runs a +Proc+ after the task
27
+ # @return [Proc] a proc to call after running the task
28
+ attr_accessor :after
29
+
30
+ def initialize(git, name, description, namespaces = ['rgitflow'])
31
+ @git = git
32
+ @name = name
33
+ @description = description
34
+ @namespaces = namespaces
35
+
36
+ yield self if block_given?
37
+
38
+ define
39
+ end
40
+
41
+ protected
42
+
43
+ def define
44
+ desc @description unless ::Rake.application.last_comment
45
+ task([*@namespaces, @name].join(":")) do
46
+ before.call if before.is_a?(Proc)
47
+ run
48
+ after.call if after.is_a?(Proc)
49
+ end
50
+ end
51
+
52
+ def run
53
+ raise NotImplementedError
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,6 @@
1
+ # Contains all of the modules and classes relevant to this gem.
2
+ module RGitFlow
3
+ # Represents this gem's current version.
4
+ # @return [String] current version
5
+ VERSION = "0.1.0"
6
+ end
data/lib/rgitflow.rb ADDED
@@ -0,0 +1,25 @@
1
+ require 'rgitflow/version'
2
+
3
+ module RGitFlow
4
+ # The root path for RGitFlow source libraries
5
+ ROOT = File.expand_path(File.dirname(__FILE__))
6
+ end
7
+
8
+ # Load Ruby core extension classes
9
+ Dir.glob(File.join(RGitFlow::ROOT, 'rgitflow', 'core_ext', '*.rb')).each do |file|
10
+ require file
11
+ end
12
+
13
+ # Load Git extension classes
14
+ Dir.glob(File.join(RGitFlow::ROOT, 'rgitflow', 'git_ext', '*.rb')).each do |file|
15
+ require file
16
+ end
17
+
18
+ ['autoload'].each do |file|
19
+ require File.join(RGitFlow::ROOT, 'rgitflow', file)
20
+ end
21
+
22
+ # Load YARD configuration options (and plugins)
23
+ RGitFlow::Config.load
24
+
25
+ RGitFlow::Install.install_tasks
data/rgitflow.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rgitflow/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rgitflow"
8
+ spec.version = RGitFlow::VERSION
9
+ spec.version = "#{spec.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}" unless ENV['TRAVIS_BUILD_NUMBER'].nil?
10
+ spec.authors = ["Richard Harrah"]
11
+ spec.email = ["topplethenunnery@gmail.com"]
12
+
13
+ spec.summary = %q{A collection of Rake tasks designed to represent Git Flow in a Ruby context.}
14
+ spec.homepage = "https://nunnery.github.io/rgitflow"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+ spec.test_files = `git ls-files -z`.split("\x0").select { |f| f.match(%r{^(test|spec|features)/}) }
22
+ spec.extra_rdoc_files = `git ls-files -z`.split("\x0").select { |f| f.match(/(.+).(txt|rdoc)/) }
23
+
24
+ spec.add_dependency 'rake', '~> 10.0'
25
+ spec.add_dependency 'git', '~> 1.2'
26
+ spec.add_dependency 'ansi', '~> 1.5'
27
+
28
+ spec.add_development_dependency 'bundler', '~> 1.10'
29
+ spec.add_development_dependency 'rspec', '~> 3.3'
30
+ spec.add_development_dependency 'yard', '~> 0.8'
31
+ spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
32
+ end
@@ -0,0 +1,5 @@
1
+ RSpec.describe 'RGitFlow' do
2
+ it 'should have a VERSION constant' do
3
+ expect(RGitFlow::VERSION).to_not be_nil
4
+ end
5
+ end
@@ -0,0 +1,33 @@
1
+ require 'rgitflow'
2
+ require 'codeclimate-test-reporter'
3
+ CodeClimate::TestReporter.start
4
+
5
+ RSpec.configure do |config|
6
+
7
+ config.expect_with :rspec do |expectations|
8
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
9
+ end
10
+
11
+ config.mock_with :rspec do |mocks|
12
+ mocks.verify_partial_doubles = true
13
+ end
14
+
15
+ config.filter_run :focus
16
+ config.run_all_when_everything_filtered = true
17
+
18
+ config.example_status_persistence_file_path = "spec/examples.txt"
19
+
20
+ config.disable_monkey_patching!
21
+
22
+ config.warnings = true
23
+
24
+ if config.files_to_run.one?
25
+ config.default_formatter = 'doc'
26
+ end
27
+
28
+ config.profile_examples = 10
29
+
30
+ config.order = :random
31
+
32
+ Kernel.srand config.seed
33
+ end
metadata ADDED
@@ -0,0 +1,177 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rgitflow
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.pre.alpha.pre.10
5
+ platform: ruby
6
+ authors:
7
+ - Richard Harrah
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '10.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '10.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: git
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: ansi
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.5'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '3.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '3.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '0.8'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '0.8'
97
+ - !ruby/object:Gem::Dependency
98
+ name: codeclimate-test-reporter
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '0.4'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '0.4'
111
+ description:
112
+ email:
113
+ - topplethenunnery@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files:
117
+ - ChangeLog.rdoc
118
+ - LICENSE.txt
119
+ files:
120
+ - .codeclimate.yml
121
+ - .document
122
+ - .gitignore
123
+ - .rspec
124
+ - .travis.yml
125
+ - .yardopts
126
+ - CODE_OF_CONDUCT.md
127
+ - ChangeLog.rdoc
128
+ - Gemfile
129
+ - LICENSE.txt
130
+ - README.md
131
+ - Rakefile
132
+ - lib/rgitflow.rb
133
+ - lib/rgitflow/autoload.rb
134
+ - lib/rgitflow/config.rb
135
+ - lib/rgitflow/core_ext/object.rb
136
+ - lib/rgitflow/core_ext/symbol_hash.rb
137
+ - lib/rgitflow/git_ext/base.rb
138
+ - lib/rgitflow/git_ext/diff.rb
139
+ - lib/rgitflow/git_ext/lib.rb
140
+ - lib/rgitflow/install.rb
141
+ - lib/rgitflow/printing.rb
142
+ - lib/rgitflow/tasks/feature/finish.rb
143
+ - lib/rgitflow/tasks/feature/start.rb
144
+ - lib/rgitflow/tasks/feature/tasks.rb
145
+ - lib/rgitflow/tasks/scm/status.rb
146
+ - lib/rgitflow/tasks/task.rb
147
+ - lib/rgitflow/version.rb
148
+ - rgitflow.gemspec
149
+ - spec/rgitflow_spec.rb
150
+ - spec/spec_helper.rb
151
+ homepage: https://nunnery.github.io/rgitflow
152
+ licenses:
153
+ - MIT
154
+ metadata: {}
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ! '>='
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ! '>'
167
+ - !ruby/object:Gem::Version
168
+ version: 1.3.1
169
+ requirements: []
170
+ rubyforge_project:
171
+ rubygems_version: 2.4.5
172
+ signing_key:
173
+ specification_version: 4
174
+ summary: A collection of Rake tasks designed to represent Git Flow in a Ruby context.
175
+ test_files:
176
+ - spec/rgitflow_spec.rb
177
+ - spec/spec_helper.rb