version_tracker 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c9ccf35a8fd399ff71c248ef6c56e67cea3f3f8
4
- data.tar.gz: 58f795cc7fc22539870662cbe709e6cd24ad280f
3
+ metadata.gz: b4adb628c383c9b7db13a434efa7ad8a5b5f12e3
4
+ data.tar.gz: df838bc2f082253c5ab5339b0fca1d09b77418a4
5
5
  SHA512:
6
- metadata.gz: cbb5de30de51935ab5ee4b609113da30ddc11c381dd76d172b2dfa51e24dd7486e46b0e76f8db96ef25a9db9a7f547fb6f3374d41003b838f2286191ac95901a
7
- data.tar.gz: 4ef94aef036c5a2ef1675ca0f783ef9fdc9e33727dcfb99a8f937bb1b6093e4514e4a2ee1379d503d0af362f276e38d865c75e5baf00f645929c07b40095fb8d
6
+ metadata.gz: 8c419dd6dcfb4fd26da5e69b00902d2adc3e25ddfcb166b32948ac9848870892b5a06a641077e1120d09ebbf9183eb5dec999070801cd2f781f92cdf69e3bc90
7
+ data.tar.gz: 70ef0b890972591ba6429d1043308fe3f229e44b82a4589c37c4853fb6223dde56213c3c57666e50a95d71e3b6ff83dd8caf67e6c223e0cf28a0d50aba2c1ed7
data/README.md CHANGED
@@ -23,12 +23,13 @@ Or install it yourself as:
23
23
 
24
24
  ### Using Command Line
25
25
  ```
26
+ version [read] # Display current VERSION
26
27
  version init [value] # Initialize VERSION File with provided value.
27
28
  # Default: 0.0.0 if value is not provided and VERSION File does not exist
28
- version read # Read current VERSION
29
- version bump [part] # Bump VERSION based on part. Valid part: major, minor, patch. Default: patch
29
+ version bump [part] # Bump VERSION based on part.
30
+ # Valid part: major, minor, patch (Default: patch)
30
31
  version tag # Tag using current VERSION
31
-
32
+
32
33
  OPTIONS:
33
34
  -r, --release Push to release branch using current version
34
35
  -m, --message=MESSAGE Push with custom commit message
data/bin/version CHANGED
@@ -11,9 +11,11 @@ option_parser =
11
11
  Version Tracker: Manages Rails Application Version
12
12
 
13
13
  USAGE:
14
- version init [value] # Initialize VERSION File with provided value. Default: 0.0.0 if value is not provided and VERSION File does not exist
15
- version read # Read current VERSION
16
- version bump [part] # Bump VERSION based on part. Valid part: major, minor, patch. Default: patch
14
+ version [read] # Display current VERSION
15
+ version init [value] # Initialize VERSION File with provided value.
16
+ # Default: 0.0.0 if value is not provided and VERSION File does not exist
17
+ version bump [part] # Bump VERSION based on part.
18
+ # Valid part: major, minor, patch (Default: patch)
17
19
  version tag # Tag using current VERSION
18
20
 
19
21
  OPTIONS:
@@ -46,6 +48,5 @@ option_parser.parse!
46
48
  result, status = VersionTracker::CommandLine.new.execute ARGV, options
47
49
 
48
50
  puts result
49
- puts option_parser if status == VersionTracker::CommandLine::RESULT_STATUS::ERROR
50
51
 
51
52
  exit status
@@ -85,20 +85,17 @@ module VersionTracker
85
85
 
86
86
 
87
87
  def release
88
+ origin_branch = self.current_branch
88
89
  branch = ['release', @version_tracker.version].join '/'
90
+ exists = system "git rev-parse --quiet --verify #{branch}"
89
91
 
90
- exists = system "git rev-parse --verify #{branch}"
91
- create_branch = '-b' unless exists
92
-
93
- system ['git', 'checkout', create_branch, branch].join(' ')
94
- self.git_commit branch
92
+ self.checkout branch, :create => !exists
93
+ self.git_push branch, origin_branch, :create => !exists
95
94
  end
96
95
 
97
96
 
98
97
  def push
99
- result = `git rev-parse --abbrev-ref HEAD`
100
- branch = result.gsub /\n/, ''
101
- self.git_commit branch
98
+ self.git_push self.current_branch
102
99
  end
103
100
 
104
101
 
@@ -107,10 +104,37 @@ module VersionTracker
107
104
  end
108
105
 
109
106
 
110
- def git_commit branch
107
+ def git_push branch, origin_branch = nil, options = {:create => false}
111
108
  system 'git add VERSION'
112
109
  system "git commit -m '#{self.message}'"
113
- system "git push origin #{branch}"
110
+
111
+ return if system("git push origin #{branch}")
112
+
113
+ self.revert_branch(origin_branch) unless origin_branch == branch
114
+ self.delete_branch branch if !!options[:create]
115
+ raise VersionTrackerError, 'Error encountered while pushing to git'
116
+ end
117
+
118
+
119
+ def current_branch
120
+ result = `git rev-parse --abbrev-ref HEAD`
121
+ result.gsub /\n/, ''
122
+ end
123
+
124
+
125
+ def checkout branch, options = {:create => false}
126
+ create_branch = '-b' if !!options[:create]
127
+ system ['git', 'checkout', create_branch, branch].join(' ')
128
+ end
129
+
130
+
131
+ def revert_branch branch
132
+ self.checkout branch
133
+ end
134
+
135
+
136
+ def delete_branch branch
137
+ system "git branch -D #{branch}"
114
138
  end
115
139
 
116
140
  end
@@ -1,3 +1,3 @@
1
1
  module VersionTracker
2
- VERSION = "0.1.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: version_tracker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braymon Ramirez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-08 00:00:00.000000000 Z
11
+ date: 2015-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler