jive 0.4.0 → 0.5.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
  SHA256:
3
- metadata.gz: 154a09fc65037768dd5356b9b09c02f2f25f8548be75663893e6867922d0f0d1
4
- data.tar.gz: 9fa27240f2f7e0f009f271e95606ac3c162b8836fa5cf4b79b31ef79271bcf2d
3
+ metadata.gz: 907ad4223ef1469a013283c0dc7c781e27ee5da0b4cb0ee6e3b7b9651cb4d986
4
+ data.tar.gz: 9bae7e21dc61f89d4272896280673e28e687f3f88d98ecddea1918f8bad92c3d
5
5
  SHA512:
6
- metadata.gz: 3dffd40c02972768c156c6755b9f01af441ae64dc715f27fd515ed10f0a4d849c5c69919129dffaf82a68f052a0950693e4613c1d035c7d8ec318a35651b72fa
7
- data.tar.gz: 5931d35f12bb6bd418ad4ac732992e3674c6dfb2dd7eec34e0691440fa4c279d3636dcd3a59564c794e5c35bf120a5839bb6436cd75dfa81a63d36bef927f094
6
+ metadata.gz: 51b4173ac6ad187e61f911418fc022d664d93ced8c540e59c6fb73cdcded37531d223160902227f95fcf2b5fb559ec73fedb42f517090d111672c035c9f82adc
7
+ data.tar.gz: 9a25ed11f67d138d940f0dcc0c3b294f99115a9cf8ebd0a725379435d8faf7fbd9fd1bd54d236b1ea63d2883f5188946e9cd05c2c95aca54ce48ff6cb1e35577
data/exe/jive CHANGED
@@ -3,4 +3,13 @@
3
3
 
4
4
  require "jive/cli"
5
5
 
6
- ::Jive::Cli::App.start(ARGV)
6
+ Signal.trap("INT") do
7
+ exit 1
8
+ end
9
+
10
+ begin
11
+ ::Jive::Cli::App.start(ARGV)
12
+ rescue StandardError => e
13
+ puts "ERROR: #{e.message}"
14
+ exit 1
15
+ end
data/jive.gemspec CHANGED
@@ -30,6 +30,8 @@ Gem::Specification.new do |spec|
30
30
  $ jive setup
31
31
  MESSAGE
32
32
 
33
+ spec.add_dependency "cli-ui", "~> 1.5"
34
+ spec.add_dependency "rugged", "~> 1.1"
33
35
  spec.add_dependency "thor", "~> 1.1"
34
36
  spec.add_development_dependency "minitest", "~> 5.0"
35
37
  spec.add_development_dependency "rake", "~> 13.0"
data/lib/jive.rb CHANGED
@@ -2,13 +2,17 @@
2
2
 
3
3
  require "fileutils"
4
4
  require "open3"
5
+ require "rugged"
6
+ require "uri"
5
7
 
6
8
  require "jive/batch_runner"
7
9
  require "jive/docker"
8
10
  require "jive/git"
11
+ require "jive/issue"
9
12
  require "jive/popen"
10
13
  require "jive/project"
11
14
  require "jive/pull_request"
15
+ require "jive/repo"
12
16
  require "jive/runner"
13
17
  require "jive/shell"
14
18
  require "jive/version"
@@ -27,4 +31,18 @@ module Jive
27
31
  def self.shell
28
32
  @shell ||= ::Jive::Shell.new
29
33
  end
34
+
35
+ def self.home
36
+ @home ||= Pathname(Dir.home).join(".jive")
37
+ end
38
+
39
+ def self.prompt?(items, display: ->(x) { x })
40
+ CLI::UI::Prompt.ask("Choose?") do |handler|
41
+ items.each do |item|
42
+ handler.option(display.call(item)) do |_selection|
43
+ return item
44
+ end
45
+ end
46
+ end
47
+ end
30
48
  end
data/lib/jive/cli.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "cli/ui"
3
4
  require "pathname"
4
5
  require "thor"
5
6
  require "yaml"
@@ -52,6 +53,22 @@ module Jive
52
53
  end
53
54
  end)
54
55
 
56
+ desc "issue SUBCOMMAND ...ARGS", "issue things"
57
+ subcommand "issue", (Class.new(Thor) do
58
+ desc "list <type>", "List the issues"
59
+ def list(type = Issue.what_type?)
60
+ issues = Issue.for(type)
61
+ issue = Jive.prompt?(issues, display: ->(x) { x.file_name })
62
+ issue.edit
63
+ end
64
+
65
+ desc "create <type>", "Create a new issue"
66
+ def create(type = Issue.what_type?)
67
+ issue = Issue.create!(name: ask("Name:"), type: type)
68
+ issue.edit
69
+ end
70
+ end)
71
+
55
72
  desc "cd <org>/<project>", "cd to ~/src/github.com/<org>/<project>"
56
73
  def cd(slug)
57
74
  Jive.shell.run_safely { Git.new(Jive.shell).cd(slug) }
@@ -74,9 +91,9 @@ module Jive
74
91
  .bootstrap(Jive.shell)
75
92
  end
76
93
 
77
- desc "pr URL", "pull request"
78
- def pr(url)
79
- pr = PullRequest.new(url)
94
+ desc "pr", "pull request"
95
+ def pr
96
+ pr = PullRequest.new(repo: Repo.current)
80
97
  pr.edit(ENV["EDITOR"])
81
98
  end
82
99
 
data/lib/jive/issue.rb ADDED
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jive
4
+ class Issue
5
+ class << self
6
+ def what_type?
7
+ Jive.prompt?(
8
+ Jive.root
9
+ .join("lib/jive/templates")
10
+ .glob("*.md")
11
+ .map { |x| x.basename.to_s.gsub(".md", "") }
12
+ )
13
+ end
14
+
15
+ def create!(name:, type:, repo: Repo.current)
16
+ new(repo: repo, name: name, type: type)
17
+ end
18
+
19
+ def for(type, repo: Repo.current)
20
+ dir_for(type, repo: repo).glob("*.md").map do |x|
21
+ name = x.basename.to_s.gsub(".md", "")
22
+ new(repo: repo, name: name, type: type)
23
+ end
24
+ end
25
+
26
+ def dir_for(type, repo: Repo.current)
27
+ Jive.home
28
+ .join(repo.uri.host)
29
+ .join(repo.nwo)
30
+ .join(type)
31
+ end
32
+ end
33
+
34
+ def initialize(name:, type:, repo: Repo.current)
35
+ @repo = repo
36
+ @type = type
37
+ @name = name
38
+ end
39
+
40
+ def file_name
41
+ "#{name.gsub(/[^a-z0-9\-_]+/i, "-").downcase}.md"
42
+ end
43
+
44
+ def edit(editor: ENV["EDITOR"])
45
+ Jive.shell.execute([editor, issue.to_s])
46
+ end
47
+
48
+ private
49
+
50
+ attr_reader :repo, :name, :type
51
+
52
+ def issue
53
+ @issue ||=
54
+ begin
55
+ dir = self.class.dir_for(type, repo: repo)
56
+ Jive.shell.execute([:mkdir, "-p", dir])
57
+ dir.join(file_name).tap do |file|
58
+ file.write(template_for(type).read) unless file.exist?
59
+ end
60
+ end
61
+ end
62
+
63
+ def template_for(type)
64
+ Jive.root.join("lib/jive/templates/#{type}.md")
65
+ end
66
+ end
67
+ end
@@ -4,9 +4,8 @@ module Jive
4
4
  class PullRequest
5
5
  attr_reader :dir, :uri
6
6
 
7
- def initialize(url)
8
- @uri = URI.parse(url)
9
- @dir = Pathname(Dir.home).join(".jive").join(uri.host).join(uri.path[1..-1])
7
+ def initialize(repo: Repo.current)
8
+ @dir = Jive.home.join(repo.uri.host).join(repo.branch)
10
9
  Jive.shell.execute([:mkdir, "-p", @dir]) unless @dir.exist?
11
10
  end
12
11
 
@@ -17,7 +16,7 @@ module Jive
17
16
  private
18
17
 
19
18
  def template
20
- Jive.root.join("lib/jive/templates/pull_request_template.md")
19
+ Jive.root.join("lib/jive/templates/pull_request.md")
21
20
  end
22
21
 
23
22
  def readme
data/lib/jive/repo.rb ADDED
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jive
4
+ class Repo
5
+ SSH_REGEX = %r{\Agit@(?<host>.+):(?<account>.+)/(?<repo>.+)\z}.freeze
6
+
7
+ def initialize(path)
8
+ @repo = Rugged::Repository.new(path.to_s)
9
+ end
10
+
11
+ def uri
12
+ @uri ||= URI.parse(canonical_url)
13
+ end
14
+
15
+ def canonical_url
16
+ remote = @repo.remotes.find { |x| x.name == "origin" }
17
+ return if remote.nil?
18
+
19
+ ssh?(remote) ? url_for_ssh(remote) : url_for(remote)
20
+ end
21
+
22
+ def nwo
23
+ segments = uri.path.split("/")
24
+ "#{segments[1]}/#{segments[2].gsub(".git", "")}"
25
+ end
26
+
27
+ def branch
28
+ uri.path[1..-1]
29
+ end
30
+
31
+ class << self
32
+ def current
33
+ @current ||= new(Pathname.pwd)
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def ssh?(remote)
40
+ remote.url.match?(SSH_REGEX)
41
+ end
42
+
43
+ def url_for_ssh(remote)
44
+ match = remote.url.match(SSH_REGEX)
45
+ [
46
+ "https:/",
47
+ match[:host],
48
+ match[:account],
49
+ match[:repo],
50
+ @repo.head.name
51
+ ].join("/")
52
+ end
53
+
54
+ def url_for(remote)
55
+ uri = URI.parse(remote.url)
56
+ [uri.host, uri.path, @repo.head.name].join("/")
57
+ end
58
+ end
59
+ end
data/lib/jive/shell.rb CHANGED
@@ -6,7 +6,7 @@ module Jive
6
6
  cd: "/usr/bin/cd",
7
7
  echo: "/usr/bin/echo",
8
8
  git: "/usr/bin/git",
9
- mkdir: "/usr/bin/mkdir"
9
+ mkdir: "/bin/mkdir"
10
10
  }.freeze
11
11
 
12
12
  def run_each(tasks)
@@ -0,0 +1,45 @@
1
+ ---
2
+ title: "Defect Template"
3
+ description: |
4
+ ---
5
+
6
+ ### Summary
7
+
8
+ <!-- Summarize the defect encountered concisely. -->
9
+
10
+ ### Steps to reproduce
11
+
12
+ <!--
13
+ Describe how one can reproduce the issue - this is very important.
14
+ Please use an ordered list.
15
+ -->
16
+
17
+ ### Example Project
18
+
19
+ <!--
20
+ Please create an example project here on GitHub.com that exhibits the problematic
21
+ behavior, and link to it here in the bug report.
22
+
23
+ If you are using an older version of GitHub.com,
24
+ this will also determine whether the bug is fixed
25
+ in a more recent version.
26
+ -->
27
+
28
+ ### What is the current *bug* behavior?
29
+
30
+ <!-- Describe what actually happens. -->
31
+
32
+ ### What is the expected *correct* behavior?
33
+
34
+ <!-- Describe what you should see instead. -->
35
+
36
+ ### Relevant logs and/or screenshots
37
+
38
+ <!--
39
+ Paste any relevant logs - please use code blocks (```) to format console output,
40
+ logs, and code.
41
+ -->
42
+
43
+ ### Possible fixes
44
+
45
+ <!-- If you can, link to the line of code that might be responsible for the problem. -->
@@ -0,0 +1,49 @@
1
+ ---
2
+ title: "Feature Template"
3
+ description: |
4
+ This is used to break-up a large piece of work into smaller,
5
+ discrete tasks that can move independently through the build workflow steps.
6
+ ---
7
+
8
+ As a `[persona]`, I `[want to]`, so that `[goal]`.
9
+
10
+ # Why are we doing this work?
11
+
12
+ <!--
13
+ A brief explanation of the why, not the what or how.
14
+ Assume the reader doesn't know the background and won't have time to dig-up
15
+ information from comment threads.
16
+ -->
17
+
18
+ # Tasks
19
+
20
+ <!--
21
+ Steps and the parts of the code that will need to get updated.
22
+ The plan can also call-out responsibilities for other team members or teams.
23
+
24
+ e.g.:
25
+
26
+ - [ ] ~frontend Step 1
27
+ - [ ] `@person` Step 1a
28
+ - [ ] ~frontend Step 2
29
+ - [ ] ~backend Step 3
30
+ -->
31
+
32
+ # Relevant links
33
+
34
+ <!--
35
+ Information that developers might need to refer to when implementing the issue.
36
+
37
+ - [Design Issue](https://github.com/xlgmokha/project/issues/<id>)
38
+ - [Similar implementation](https://github.com/xlgmokha/project/pull/<id>)
39
+ -->
40
+
41
+ # Non-functional requirements
42
+
43
+ <!-- Add details for required items and delete others. -->
44
+
45
+ - [ ] Documentation:
46
+ - [ ] Feature flag:
47
+ - [ ] Observability:
48
+ - [ ] Performance:
49
+ - [ ] Testing:
@@ -1,6 +1,15 @@
1
- # Pull Request Template
1
+ ---
2
+ title: "Pull Request Template"
3
+ checklist:
4
+ - [ ] Clear description explaining the relevancy of the contribution.
5
+ - [ ] Unit, integration, and system tests.
6
+ - [ ] Regression and bugs are covered with tests.
7
+ - [ ] [Performance guidelines](https://docs.gitlab.com/ee/development/merge_request_performance_guidelines.html)
8
+ - [ ] [Secure coding guidelines](https://docs.gitlab.com/ee/development/secure_coding_guidelines.html)
9
+ - [ ] Documentation Updated
10
+ ---
2
11
 
3
- ## Why is this needed?
12
+ # Why is this needed?
4
13
 
5
14
  ## What does this do?
6
15
 
@@ -16,15 +25,15 @@ Fixes # (issue)
16
25
 
17
26
  Before:
18
27
 
19
- ![before]()
28
+ ![Before][before]
20
29
 
21
30
  After:
22
31
 
23
- ![after]()
32
+ ![After][after]
24
33
 
25
34
  ## Type of change
26
35
 
27
- Delete options that are not relevant.
36
+ <!-- Delete options that are not relevant. -->
28
37
 
29
38
  - [ ] Bug fix (non-breaking change which fixes an issue)
30
39
  - [ ] New feature (non-breaking change which adds functionality)
@@ -33,19 +42,10 @@ Delete options that are not relevant.
33
42
 
34
43
  ## Verification Plan
35
44
 
36
- How are we going to verify this change?
45
+ <!-- How are we going to verify this change? -->
37
46
 
38
47
  - [ ] Step 1
39
48
  - [ ] Step 2
40
49
 
41
- ## Checklist
42
-
43
- - [ ] Clear description explaining the relevancy of the contribution.
44
- - [ ] Unit, integration, and system tests.
45
- - [ ] Regression and bugs are covered with tests.
46
- - [ ] [Performance guidelines][performance]
47
- - [ ] [Secure coding guidelines][secure]
48
- - [ ] Documentation Updated
49
-
50
- [performance]: https://docs.gitlab.com/ee/development/merge_request_performance_guidelines.html
51
- [secure]: https://docs.gitlab.com/ee/development/secure_coding_guidelines.html
50
+ [after]: https://user-images.githubusercontent.com/x/y.png
51
+ [before]: https://user-images.githubusercontent.com/x/y.png
data/lib/jive/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jive
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mo khan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-28 00:00:00.000000000 Z
11
+ date: 2021-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cli-ui
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rugged
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: thor
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -112,12 +140,16 @@ files:
112
140
  - lib/jive/cli.rb
113
141
  - lib/jive/docker.rb
114
142
  - lib/jive/git.rb
143
+ - lib/jive/issue.rb
115
144
  - lib/jive/popen.rb
116
145
  - lib/jive/project.rb
117
146
  - lib/jive/pull_request.rb
147
+ - lib/jive/repo.rb
118
148
  - lib/jive/runner.rb
119
149
  - lib/jive/shell.rb
120
- - lib/jive/templates/pull_request_template.md
150
+ - lib/jive/templates/bug.md
151
+ - lib/jive/templates/feature.md
152
+ - lib/jive/templates/pull_request.md
121
153
  - lib/jive/version.rb
122
154
  homepage: https://rubygems.org/gems/jive
123
155
  licenses: