git-story-workflow 0.0.7 → 0.1.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: 604d9f538483bddd638458e260340f843912626f
4
- data.tar.gz: c4f7f61e8f34a2a270de9ef49de90440c67a2e91
3
+ metadata.gz: fe8b6f199d9df21a308c6d494263d23e1012d09b
4
+ data.tar.gz: 529e161298bc68321c64f80bd2f17f8c8b655edd
5
5
  SHA512:
6
- metadata.gz: ca18fef7ef837044280e3c856857d4f7dc5d2196ff486a3d98f673333474d224b342dc6352d01960fa65f0a6ae55417b6c544c817547ac9ef7aeaa3025a5e54f
7
- data.tar.gz: a4a5fb4c523a2a6a7eb6a912cbb8fd4134d786a27f4253b566630764a4134564856bb83c264bf38019b5e402d7d44d396a59f916351a9fee76330df67be8fad8
6
+ metadata.gz: b67ab71e2cd391093edaeda3ade6abe8912a05b08bbe6404108be9371f7504c3f6927246677359a9b58f61d59e1478a19ad1cd4c4bb82aca45bf5db8c8324a33
7
+ data.tar.gz: 66986d41d661df40092575db515874bffb6eba3e98ecee559709087157e4b77ad3e13978f23c4a61cdfda5f66f9b7b4cd76228ed1ee397c8f66bda63ab2ed7ad
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.1.0
@@ -1,19 +1,19 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: git-story-workflow 0.0.7 ruby lib
2
+ # stub: git-story-workflow 0.1.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "git-story-workflow".freeze
6
- s.version = "0.0.7"
6
+ s.version = "0.1.0"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Florian Frank".freeze]
11
- s.date = "2017-10-17"
11
+ s.date = "2017-11-23"
12
12
  s.description = "Gem abstracting a git workflow\u2026".freeze
13
13
  s.email = "flori@ping.de".freeze
14
14
  s.executables = ["git-story".freeze]
15
- s.extra_rdoc_files = ["README.md".freeze, "lib/git/story.rb".freeze, "lib/git/story/app.rb".freeze, "lib/git/story/setup.rb".freeze, "lib/git/story/utils.rb".freeze, "lib/git/story/version.rb".freeze]
16
- s.files = [".gitignore".freeze, "COPYING".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/git-story".freeze, "config/story.yml".freeze, "git-story-workflow.gemspec".freeze, "lib/git/story.rb".freeze, "lib/git/story/app.rb".freeze, "lib/git/story/prepare-commit-msg".freeze, "lib/git/story/setup.rb".freeze, "lib/git/story/utils.rb".freeze, "lib/git/story/version.rb".freeze, "spec/git/story/app_spec.rb".freeze, "spec/spec_helper.rb".freeze]
15
+ s.extra_rdoc_files = ["README.md".freeze, "lib/git/story.rb".freeze, "lib/git/story/app.rb".freeze, "lib/git/story/semaphore.rb".freeze, "lib/git/story/setup.rb".freeze, "lib/git/story/utils.rb".freeze, "lib/git/story/version.rb".freeze]
16
+ s.files = [".gitignore".freeze, "COPYING".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/git-story".freeze, "config/story.yml".freeze, "git-story-workflow.gemspec".freeze, "lib/git/story.rb".freeze, "lib/git/story/app.rb".freeze, "lib/git/story/prepare-commit-msg".freeze, "lib/git/story/semaphore.rb".freeze, "lib/git/story/setup.rb".freeze, "lib/git/story/utils.rb".freeze, "lib/git/story/version.rb".freeze, "spec/git/story/app_spec.rb".freeze, "spec/spec_helper.rb".freeze]
17
17
  s.homepage = "http://flori.github.com/git-story-workflow".freeze
18
18
  s.licenses = ["Apache-2.0".freeze]
19
19
  s.rdoc_options = ["--title".freeze, "Git-story-workflow".freeze, "--main".freeze, "README.md".freeze]
data/lib/git/story.rb CHANGED
@@ -21,4 +21,5 @@ end
21
21
  require 'git/story/version'
22
22
  require 'git/story/utils'
23
23
  require 'git/story/setup'
24
+ require 'git/story/semaphore'
24
25
  require 'git/story/app'
data/lib/git/story/app.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'time'
2
+ require 'open-uri'
2
3
 
3
4
  class Git::Story::App
4
5
  class ::String
@@ -84,6 +85,32 @@ class Git::Story::App
84
85
  end
85
86
  end
86
87
 
88
+ command doc: '[BRANCH] display build status of branch'
89
+ def build_status(branch = current(check: false))
90
+ auth_token = complex_config.story.semaphore_auth_token
91
+ project = complex_config.story.semaphore_project
92
+ url = "https://semaphoreci.com/api/v1/projects/#{project}/#{branch}/status?auth_token=#{auth_token}"
93
+ Git::Story::SemaphoreResponse.get(url)
94
+ rescue => e
95
+ "Getting #{url.inspect} => #{e.class}: #{e}".red
96
+ end
97
+
98
+ command doc: '[SERVER] display deploy status of branch'
99
+ def deploy_status(server = complex_config.story.semaphore_default_server)
100
+ auth_token = complex_config.story.semaphore_auth_token
101
+ project = complex_config.story.semaphore_project
102
+ url = "https://semaphoreci.com/api/v1/projects/#{project}/servers/#{server}?auth_token=#{auth_token}"
103
+ deploys = Git::Story::SemaphoreResponse.get(url).deploys
104
+ upcoming = deploys.select(&:pending?)&.last
105
+ current = deploys.find(&:passed?)
106
+ <<~end
107
+ Upcoming: #{upcoming}
108
+ Current: #{current}
109
+ end
110
+ rescue => e
111
+ "Getting #{url.inspect} => #{e.class}: #{e}".red
112
+ end
113
+
87
114
  command doc: '[AUTHOR] list all stories'
88
115
  def list(author = nil, mark_red: current(check: false))
89
116
  stories.map { |b|
@@ -0,0 +1,77 @@
1
+ require 'json'
2
+ require 'time'
3
+ require 'open-uri'
4
+
5
+ class Git::Story::SemaphoreResponse < JSON::GenericObject
6
+ def self.get(url, debug: false)
7
+ data = open(url).read
8
+ debug and STDERR.puts JSON.pretty_generate(JSON(data))
9
+ JSON(data, object_class: self)
10
+ end
11
+
12
+ def duration(time = nil)
13
+ unless time
14
+ if finished_at.nil?
15
+ time = Time.now
16
+ else
17
+ time = Time.parse(finished_at)
18
+ end
19
+ end
20
+ Tins::Duration.new(time - Time.parse(started_at))
21
+ end
22
+
23
+ def pending?
24
+ result == 'pending'
25
+ end
26
+
27
+ def building?
28
+ !started_at.nil?
29
+ end
30
+
31
+ def passed?
32
+ result == 'passed'
33
+ end
34
+
35
+ def failed?
36
+ result == 'failed'
37
+ end
38
+
39
+ def canceled?
40
+ result == 'canceled'
41
+ end
42
+
43
+ def finished?
44
+ finished_at.blank?
45
+ end
46
+
47
+ def sha1
48
+ commit.id[0,10]
49
+ end
50
+
51
+ def entity_url
52
+ server_html_url || build_url
53
+ end
54
+
55
+ def entity_name
56
+ branch_name || server_name
57
+ end
58
+
59
+ def to_s
60
+ r = case
61
+ when pending? && building?
62
+ "#{entity_name} ##{sha1} building for #{duration(Time.now)}".yellow.bold
63
+ when pending?
64
+ "#{entity_name} ##{sha1} pending at the moment".yellow
65
+ when passed?
66
+ "#{entity_name} ##{sha1} passed after #{duration}".green
67
+ when failed?
68
+ "#{entity_name} ##{sha1} failed after #{duration}".red
69
+ else
70
+ "#{entity_name} ##{sha1} in state #{result}".blue
71
+ end
72
+ r <<
73
+ "\n Semaphore: #{entity_url}" <<
74
+ "\n Commit: #{commit.url}" <<
75
+ "\n Authored: #{(commit.author_name + ' <' + commit.author_email + ?>).bold} @#{commit.timestamp}"
76
+ end
77
+ end
@@ -1,6 +1,6 @@
1
1
  module Git::Story
2
2
  # Git::Story version
3
- VERSION = '0.0.7'
3
+ VERSION = '0.1.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-story-workflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-17 00:00:00.000000000 Z
11
+ date: 2017-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar
@@ -131,6 +131,7 @@ extra_rdoc_files:
131
131
  - README.md
132
132
  - lib/git/story.rb
133
133
  - lib/git/story/app.rb
134
+ - lib/git/story/semaphore.rb
134
135
  - lib/git/story/setup.rb
135
136
  - lib/git/story/utils.rb
136
137
  - lib/git/story/version.rb
@@ -147,6 +148,7 @@ files:
147
148
  - lib/git/story.rb
148
149
  - lib/git/story/app.rb
149
150
  - lib/git/story/prepare-commit-msg
151
+ - lib/git/story/semaphore.rb
150
152
  - lib/git/story/setup.rb
151
153
  - lib/git/story/utils.rb
152
154
  - lib/git/story/version.rb