jiragit 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +112 -0
- data/Rakefile +18 -0
- data/bin/jiragit +5 -0
- data/hooks/commit-msg +90 -0
- data/hooks/post-checkout +107 -0
- data/hooks/post-commit +51 -0
- data/hooks/prepare-commit-msg +144 -0
- data/lib/jiragit.rb +10 -0
- data/lib/jiragit/cli.rb +249 -0
- data/lib/jiragit/configuration.rb +51 -0
- data/lib/jiragit/git/branch.rb +29 -0
- data/lib/jiragit/git/commit_response.rb +23 -0
- data/lib/jiragit/git/repository.rb +222 -0
- data/lib/jiragit/jira_store.rb +48 -0
- data/lib/jiragit/logger.rb +32 -0
- data/lib/jiragit/tag.rb +30 -0
- data/lib/jiragit/vault.rb +113 -0
- data/lib/jiragit/version.rb +3 -0
- data/spec/branch_spec.rb +105 -0
- data/spec/cli_context.rb +13 -0
- data/spec/cli_spec.rb +149 -0
- data/spec/commit_message_spec.rb +82 -0
- data/spec/commit_spec.rb +81 -0
- data/spec/configuration_spec.rb +32 -0
- data/spec/git_editor.rb +40 -0
- data/spec/git_editor_spec.rb +59 -0
- data/spec/jira_store_spec.rb +57 -0
- data/spec/logger_spec.rb +37 -0
- data/spec/merge_spec.rb +85 -0
- data/spec/spec_helper.rb +19 -0
- data/spec/tag_spec.rb +35 -0
- data/spec/test_repository_context.rb +17 -0
- data/spec/test_support.rb +81 -0
- data/spec/vault_spec.rb +100 -0
- metadata +124 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'rspec/mocks'
|
3
|
+
require './lib/jiragit.rb'
|
4
|
+
require './spec/test_support.rb'
|
5
|
+
require './spec/test_repository_context.rb'
|
6
|
+
require './spec/cli_context.rb'
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
include TestSupport
|
10
|
+
|
11
|
+
config.color = true
|
12
|
+
config.formatter = :documentation
|
13
|
+
|
14
|
+
config.before(:suite) do
|
15
|
+
install_gemfile
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
data/spec/tag_spec.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require './spec/spec_helper'
|
2
|
+
|
3
|
+
module Jiragit
|
4
|
+
|
5
|
+
describe Tag do
|
6
|
+
|
7
|
+
subject { described_class.new tag_type: "tag_label" }
|
8
|
+
|
9
|
+
it "requires a type and label passed in via hash" do
|
10
|
+
expect(subject).to be_a Tag
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should provide a formatted output" do
|
14
|
+
expect(subject.to_s).to eq('tag_type: tag_label')
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should be unique in a set based on type and label" do
|
18
|
+
tag1 = described_class.new tag_type: "tag_label"
|
19
|
+
tag2 = described_class.new tag_type: "tag_label"
|
20
|
+
tag3 = described_class.new tag_type: "a_different_tag_label"
|
21
|
+
|
22
|
+
set = Set.new
|
23
|
+
set << tag1
|
24
|
+
set << tag2
|
25
|
+
set << tag3
|
26
|
+
|
27
|
+
expect(set.size).to eq(2)
|
28
|
+
expect(set).to include tag1
|
29
|
+
expect(set).to include tag2
|
30
|
+
expect(set).to include tag3
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
RSpec.shared_context "Test Repository" do
|
2
|
+
|
3
|
+
before do
|
4
|
+
@config = Jiragit::Configuration.new("#{`echo ~`.chomp}/.jiragit")
|
5
|
+
@config[:jira_url] = "http://test.url"
|
6
|
+
@repository = "test_repository"
|
7
|
+
@repo = create_test_repository(@repository)
|
8
|
+
@js = Jiragit::JiraStore.new("#{@repository}/.git/jiragit/jira_store")
|
9
|
+
@log = "#{@repository}/.git/jiragit/hooks.log"
|
10
|
+
@debug = false
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
@repo.remove
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require './lib/jiragit.rb'
|
3
|
+
require 'expect'
|
4
|
+
|
5
|
+
module TestSupport
|
6
|
+
|
7
|
+
def install_gemfile
|
8
|
+
rake = Rake.application
|
9
|
+
rake.init
|
10
|
+
rake.load_rakefile
|
11
|
+
rake['gem:install'].invoke
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_test_repository(repository)
|
15
|
+
repo = Jiragit::Git::Repository.create(repository)
|
16
|
+
repo.make_a_commit
|
17
|
+
repo.origin = "git@github.com:thirtysixthspan/jiragit_test.git"
|
18
|
+
Dir.chdir repository
|
19
|
+
Jiragit::Cli.new([:install, :silent])
|
20
|
+
Dir.chdir '..'
|
21
|
+
repo
|
22
|
+
end
|
23
|
+
|
24
|
+
def checkout_a_new_branch(branch, jira="")
|
25
|
+
if jira.empty?
|
26
|
+
text = branch
|
27
|
+
else
|
28
|
+
text = 'JIRA'
|
29
|
+
end
|
30
|
+
@repo.checkout_new_branch(branch) do |output, input|
|
31
|
+
output.expect(text, 20) do |message|
|
32
|
+
puts "new #{message}" if @debug
|
33
|
+
expect(message).to_not be nil
|
34
|
+
end
|
35
|
+
input.puts(jira) if !jira.empty?
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def checkout_a_new_branch_with_default(branch)
|
40
|
+
@repo.checkout_new_branch(branch) do |output, input|
|
41
|
+
output.expect(']>', 20) do |message|
|
42
|
+
puts "new default #{message}" if @debug
|
43
|
+
expect(message).to_not be nil
|
44
|
+
end
|
45
|
+
input.puts ""
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def checkout_an_existing_branch(branch, jira="")
|
50
|
+
if jira.empty?
|
51
|
+
text = branch
|
52
|
+
else
|
53
|
+
text = 'JIRA'
|
54
|
+
end
|
55
|
+
@repo.checkout_branch(branch) do |output, input|
|
56
|
+
output.expect(text, 20) do |message|
|
57
|
+
puts "existing #{message}" if @debug
|
58
|
+
expect(message).to_not be nil
|
59
|
+
end
|
60
|
+
input.puts(jira) if !jira.empty?
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def assert_no_relation(first, second)
|
65
|
+
sleep(5)
|
66
|
+
relations = @js.relations(first)
|
67
|
+
expect(relations).to_not include Jiragit::Tag.new(second)
|
68
|
+
end
|
69
|
+
|
70
|
+
def assert_relation(first, second)
|
71
|
+
sleep(5)
|
72
|
+
relations = @js.relations(first)
|
73
|
+
expect(relations).to include Jiragit::Tag.new(second)
|
74
|
+
end
|
75
|
+
|
76
|
+
def assert_log_contains(regex)
|
77
|
+
expect(File.exists?(@log)).to be true
|
78
|
+
expect(`cat #{@log}`).to match(regex)
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
data/spec/vault_spec.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
require './spec/spec_helper'
|
2
|
+
|
3
|
+
module Jiragit
|
4
|
+
|
5
|
+
describe Vault do
|
6
|
+
|
7
|
+
let!(:vault) { described_class.new('.testvault') }
|
8
|
+
let(:item) { Tag.new(type: 'label') }
|
9
|
+
let(:related_item) { Tag.new(type: 'label2') }
|
10
|
+
let(:another_related_item) { Tag.new(type: 'label3') }
|
11
|
+
let(:a_third_related_item) { Tag.new(type: 'label4') }
|
12
|
+
let(:unrelated_item) { Tag.new(type: 'label5') }
|
13
|
+
|
14
|
+
after do
|
15
|
+
File.delete('.testvault')
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should create a vault file" do
|
19
|
+
expect(File.exists?('.testvault')).to be true
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should add items" do
|
23
|
+
vault.create
|
24
|
+
vault.add(item)
|
25
|
+
expect(vault.include?(item)).to be true
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should relate items" do
|
29
|
+
vault.create
|
30
|
+
vault.relate(item, related_item)
|
31
|
+
vault.add(unrelated_item)
|
32
|
+
expect(vault.include?(item)).to be true
|
33
|
+
expect(vault.include?(related_item)).to be true
|
34
|
+
expect(vault.related?(item, related_item)).to be true
|
35
|
+
expect(vault.include?(unrelated_item)).to be true
|
36
|
+
expect(vault.related?(item,unrelated_item)).to be false
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should relate multiple items" do
|
40
|
+
vault.create
|
41
|
+
vault.relate(item, related_item, another_related_item)
|
42
|
+
vault.add(unrelated_item)
|
43
|
+
expect(vault.include?(item)).to be true
|
44
|
+
expect(vault.include?(related_item)).to be true
|
45
|
+
expect(vault.related?(item, related_item)).to be true
|
46
|
+
expect(vault.include?(another_related_item)).to be true
|
47
|
+
expect(vault.related?(item, another_related_item)).to be true
|
48
|
+
expect(vault.include?(unrelated_item)).to be true
|
49
|
+
expect(vault.related?(item, unrelated_item)).to be false
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should store relations without self reference" do
|
53
|
+
vault.create
|
54
|
+
vault.relate(item, related_item, another_related_item)
|
55
|
+
expect(vault.relations(item)).not_to include item
|
56
|
+
expect(vault.relations(item)).to include related_item
|
57
|
+
expect(vault.relations(item)).to include another_related_item
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should build relation chains across one item" do
|
61
|
+
vault.create
|
62
|
+
chain = [item, related_item, another_related_item]
|
63
|
+
vault.relate(item, related_item)
|
64
|
+
vault.relate(related_item, another_related_item)
|
65
|
+
expect(vault.relation_chain(item, another_related_item)).to eq chain
|
66
|
+
expect(vault.distally_related?(item, another_related_item)).to eq true
|
67
|
+
expect(vault.distally_related?(another_related_item, item)).to eq true
|
68
|
+
expect(vault.distally_related?(item, unrelated_item)).to eq false
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should build relation chains across more than one item" do
|
72
|
+
vault.create
|
73
|
+
chain = [item, related_item, another_related_item, a_third_related_item]
|
74
|
+
vault.relate(item, related_item)
|
75
|
+
vault.relate(related_item, another_related_item)
|
76
|
+
vault.relate(another_related_item, a_third_related_item)
|
77
|
+
expect(vault.relation_chain(item, a_third_related_item)).to eq chain
|
78
|
+
expect(vault.distally_related?(item, a_third_related_item)).to eq true
|
79
|
+
expect(vault.distally_related?(a_third_related_item, item)).to eq true
|
80
|
+
expect(vault.distally_related?(item, unrelated_item)).to eq false
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should save and load thousand items in less than a tenth of a second" do
|
84
|
+
vault.create
|
85
|
+
1000.times.each do |i|
|
86
|
+
tag1 = Tag.new(jira: "PA-#{i}")
|
87
|
+
tag2 = Tag.new(branch: "my-feature-branch-#{i}")
|
88
|
+
vault.relate(tag1, tag2)
|
89
|
+
end
|
90
|
+
|
91
|
+
start_time = Time.now.to_f
|
92
|
+
vault.save
|
93
|
+
vault.load
|
94
|
+
end_time = Time.now.to_f
|
95
|
+
expect(end_time - start_time).to be < 0.1
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jiragit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Derrick Parkhurst
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
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: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.1'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.1'
|
41
|
+
description: add jira numbers and urls to your commits automatically
|
42
|
+
email:
|
43
|
+
- derrick.parkhurst@gmail.com
|
44
|
+
executables:
|
45
|
+
- jiragit
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- LICENSE.txt
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- bin/jiragit
|
53
|
+
- hooks/commit-msg
|
54
|
+
- hooks/post-checkout
|
55
|
+
- hooks/post-commit
|
56
|
+
- hooks/prepare-commit-msg
|
57
|
+
- lib/jiragit.rb
|
58
|
+
- lib/jiragit/cli.rb
|
59
|
+
- lib/jiragit/configuration.rb
|
60
|
+
- lib/jiragit/git/branch.rb
|
61
|
+
- lib/jiragit/git/commit_response.rb
|
62
|
+
- lib/jiragit/git/repository.rb
|
63
|
+
- lib/jiragit/jira_store.rb
|
64
|
+
- lib/jiragit/logger.rb
|
65
|
+
- lib/jiragit/tag.rb
|
66
|
+
- lib/jiragit/vault.rb
|
67
|
+
- lib/jiragit/version.rb
|
68
|
+
- spec/branch_spec.rb
|
69
|
+
- spec/cli_context.rb
|
70
|
+
- spec/cli_spec.rb
|
71
|
+
- spec/commit_message_spec.rb
|
72
|
+
- spec/commit_spec.rb
|
73
|
+
- spec/configuration_spec.rb
|
74
|
+
- spec/git_editor.rb
|
75
|
+
- spec/git_editor_spec.rb
|
76
|
+
- spec/jira_store_spec.rb
|
77
|
+
- spec/logger_spec.rb
|
78
|
+
- spec/merge_spec.rb
|
79
|
+
- spec/spec_helper.rb
|
80
|
+
- spec/tag_spec.rb
|
81
|
+
- spec/test_repository_context.rb
|
82
|
+
- spec/test_support.rb
|
83
|
+
- spec/vault_spec.rb
|
84
|
+
homepage: https://github.com/thirtysixthspan/jiragit
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.2.2
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Integrate Jira and Git
|
108
|
+
test_files:
|
109
|
+
- spec/branch_spec.rb
|
110
|
+
- spec/cli_context.rb
|
111
|
+
- spec/cli_spec.rb
|
112
|
+
- spec/commit_message_spec.rb
|
113
|
+
- spec/commit_spec.rb
|
114
|
+
- spec/configuration_spec.rb
|
115
|
+
- spec/git_editor.rb
|
116
|
+
- spec/git_editor_spec.rb
|
117
|
+
- spec/jira_store_spec.rb
|
118
|
+
- spec/logger_spec.rb
|
119
|
+
- spec/merge_spec.rb
|
120
|
+
- spec/spec_helper.rb
|
121
|
+
- spec/tag_spec.rb
|
122
|
+
- spec/test_repository_context.rb
|
123
|
+
- spec/test_support.rb
|
124
|
+
- spec/vault_spec.rb
|