agita 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +8 -0
  3. data/lib/agita/version.rb +3 -0
  4. data/lib/agita.rb +64 -0
  5. metadata +85 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8c52ce68571ba6d74d097f27f6cd873931cc1532
4
+ data.tar.gz: d91a0ff64160a2e48e3df486486daa3c1c0b98bf
5
+ SHA512:
6
+ metadata.gz: 888d193a9ea84eb1617cac7028f5363d999dac6c8e6788daebf3e19bdd40193213f264805662e7153e5801a8e1acc9ca7b197b0afffef9c4fe45ff104a478c45
7
+ data.tar.gz: 25fd7572f56b6de5dc3cc23792d31ce41ae57667717b686e30a85e907186fabbad1ed4562dde08c63b08ad511e8c0ad4f9eef826278e3e953bdd544529f6dbea
data/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # agita
2
+
3
+ * Home: [https://github.com/fornellas/agita/](https://github.com/fornellas/agita/)
4
+ * Bugs: [https://github.com/fornellas/agita/issues](https://github.com/fornellas/agita/issues)
5
+
6
+ ## Description
7
+
8
+ Git commands / workflow helper.
@@ -0,0 +1,3 @@
1
+ class Agita
2
+ VERSION = '0.1.0'
3
+ end
data/lib/agita.rb ADDED
@@ -0,0 +1,64 @@
1
+ require 'shellwords'
2
+
3
+ # Git commands / workflow helper.
4
+ class Agita
5
+
6
+ # Raise RuntimeError unless
7
+ def ensure_master_updated_clean
8
+ ensure_status(
9
+ "On branch master",
10
+ "Your branch is up-to-date with 'origin/master'.",
11
+ "nothing to commit, working directory clean"
12
+ )
13
+ end
14
+
15
+ # Raise RuntimeError unless current #status is same as expected_status.
16
+ def ensure_status *expected_status
17
+ current_status = status
18
+ unless current_status == expected_status
19
+ raise RuntimeError.new(
20
+ "Expected Git status to be:\n" +
21
+ expected_status.map{|l| " #{l}"}.join("\n") + "\n" +
22
+ "but it currently is:\n" +
23
+ current_status.map{|l| " #{l}"}.join("\n")
24
+ )
25
+ end
26
+ end
27
+
28
+ # Return Git status (git status --branch --porcelain --long) as an array.
29
+ def status
30
+ run('git status --branch --porcelain --long').split(/\n+/)
31
+ end
32
+
33
+ # Commit path with message.
34
+ # If there is nothnig to be commited (git status is clean), returns false. Otherwise, does commit and returns true.
35
+ def commit message, *paths
36
+ return false if clean?(*paths)
37
+ file_list = paths.map { |path| Shellwords.escape(path) }
38
+ run "git add #{file_list.join(' ')}"
39
+ run "git commit --quiet -m #{Shellwords.escape(message)}"
40
+ run "git push --quiet"
41
+ true
42
+ end
43
+
44
+ # Returns true if path is clean (nothing to commit).
45
+ def clean? *paths
46
+ file_list = paths.map { |path| Shellwords.escape(path) }
47
+ run("git status --porcelain #{file_list.join(' ')}") == ''
48
+ end
49
+
50
+ # Creates and push an annotated tag
51
+ def tag tagname, message
52
+ run("git tag --annotate #{Shellwords.escape(tagname)} --message=#{Shellwords.escape(message)}")
53
+ run("git push --quiet origin #{Shellwords.escape(tagname)}")
54
+ end
55
+
56
+ private
57
+
58
+ def run command
59
+ output = `#{command}`
60
+ raise "#{command} returned non-zero status:\n#{output}" unless $?.exitstatus == 0
61
+ output
62
+ end
63
+
64
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: agita
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Fabio Pugliese Ornellas
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.4'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: simplecov
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.11'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.11.1
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '0.11'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.11.1
47
+ description: Git commands / workflow helper.
48
+ email: fabio.ornellas@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files:
52
+ - README.md
53
+ files:
54
+ - README.md
55
+ - lib/agita.rb
56
+ - lib/agita/version.rb
57
+ homepage: https://github.com/fornellas/agita
58
+ licenses: []
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options:
62
+ - "--main"
63
+ - README.md
64
+ - lib/
65
+ - README.md
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.4.5.1
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Git commands / workflow helper.
84
+ test_files: []
85
+ has_rdoc: