Class: GitRollback
- Inherits:
-
Object
- Object
- GitRollback
- Defined in:
- lib/git-rollback.rb,
lib/git-rollback/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize ⇒ GitRollback
constructor
A new instance of GitRollback.
- #process_argv(argv) ⇒ Object
- #run(opts, argv) ⇒ Object
Constructor Details
#initialize ⇒ GitRollback
Returns a new instance of GitRollback.
8 9 10 |
# File 'lib/git-rollback.rb', line 8 def initialize @config = {} end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/git-rollback.rb', line 6 def config @config end |
Instance Method Details
#process_argv(argv) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/git-rollback.rb', line 22 def process_argv(argv) case argv when [] config[:n] = 1 else config[:n] = argv.first || '1' end end |
#run(opts, argv) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/git-rollback.rb', line 12 def run(opts, argv) process_argv(argv) command = ['git', 'reset'] command << (opts.hard? ? '--hard' : '--soft') command << "HEAD~#{config[:n]}" system(*command) end |