jive 0.4.1 → 0.6.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: fddf38d8a9e9a26f7e44618178a02bcdb40c23653b89be08bc25ddc1ba32171e
4
- data.tar.gz: 0f1bf89c4f67e8ff776473384802de77548ad675dc4b305552ecc62b0ce3cd6c
3
+ metadata.gz: 7e2c1ab6f78c5ed071fde65c73d5f6237de8563e07ed5be37553ad12481d0d3e
4
+ data.tar.gz: 7b7dfb21f093ef2d822100f3e4b678f1b1483043e7777658eb3049d6833fade0
5
5
  SHA512:
6
- metadata.gz: 113ec6a22efdae9d7ca05c1d4aee4d25f8e368e5aa94a1607cd7edbdd9ff1c5cb1acfb0cdcdaa393837cb8f0f236d28c06ed49e3276e188e4f41ede3fb7a3153
7
- data.tar.gz: 1515f6c8a46c26465f3315c2082adbc5d4c973d2146e73eb854208ca9564e832ef481bc5b037f570bdc6f14915c62a319beb6e1d873bcd1635be1b0634a55914
6
+ metadata.gz: 2411bbb13f2a29c6b6491e2a8424426f1406df40761fd82394f13a06f225a1406eb060e889fb11fdd6573dd7df49c74a0237b76b5186f42b884faed54a70e786
7
+ data.tar.gz: 3a9ccc541687fe4da594ea0ea421d76b4524203d246c8cf6b5ba8654189a082a980ac39001c12206f42a94ed7a2caf2af65ed1a922c330c430035ee1eb4728a2
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/jive.sh CHANGED
@@ -56,6 +56,10 @@ __jive_execute_task() {
56
56
  # shellcheck disable=SC2164
57
57
  cd "${task//cd:/}"
58
58
  ;;
59
+ ctags:*)
60
+ # shellcheck disable=SC2164
61
+ ctags -R "${task//ctags:/}"
62
+ ;;
59
63
  setenv:*)
60
64
  export "${task//setenv:/}"
61
65
  ;;
data/lib/jive.rb CHANGED
@@ -2,14 +2,17 @@
2
2
 
3
3
  require "fileutils"
4
4
  require "open3"
5
+ require "rugged"
5
6
  require "uri"
6
7
 
7
8
  require "jive/batch_runner"
8
9
  require "jive/docker"
9
10
  require "jive/git"
11
+ require "jive/issue"
10
12
  require "jive/popen"
11
13
  require "jive/project"
12
14
  require "jive/pull_request"
15
+ require "jive/repo"
13
16
  require "jive/runner"
14
17
  require "jive/shell"
15
18
  require "jive/version"
@@ -28,4 +31,18 @@ module Jive
28
31
  def self.shell
29
32
  @shell ||= ::Jive::Shell.new
30
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
31
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/git.rb CHANGED
@@ -22,6 +22,7 @@ module Jive
22
22
  if dir.exist?
23
23
  shell.after_run([
24
24
  ["cd", dir],
25
+ ["ctags", dir],
25
26
  ["setenv", "JIVE_LAST_RUN=#{Time.now.to_i}"]
26
27
  ])
27
28
  else
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.1"
4
+ VERSION = "0.6.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.1
4
+ version: 0.6.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-31 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:
@@ -142,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
174
  - !ruby/object:Gem::Version
143
175
  version: '0'
144
176
  requirements: []
145
- rubygems_version: 3.2.3
177
+ rubygems_version: 3.2.18
146
178
  signing_key:
147
179
  specification_version: 4
148
180
  summary: The art just comes.