tmp-repo 1.0.1 → 1.1.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 +4 -4
- data/History.txt +4 -0
- data/lib/tmp-repo.rb +7 -3
- data/lib/tmp-repo/version.rb +1 -1
- data/spec/tmp-repo_spec.rb +25 -14
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b34ec0171c4a211c5561a120206a5e99b8fb2f79
|
4
|
+
data.tar.gz: 00f9fe4942fcd57e58ef7fb7dee6f41860c099fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f93b09ae80e0b6cba805471932acae34f4c4b5504bcd1558f1d5ed9cfefa855dbc6bc1c0db584c49e9f32bf3516f084b781f8cc7e63e02cb3eaea67a36f96ed
|
7
|
+
data.tar.gz: ba4ecd23c17dcc580d2140855c28b539624023621cf8b7def8d42667bdd848443598d80e9e6f42fde97b21dd135a7b5e826633c57983c05a1e14c827b71d3c68
|
data/History.txt
CHANGED
data/lib/tmp-repo.rb
CHANGED
@@ -42,6 +42,10 @@ class TmpRepo
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
def each_commit_id(&block)
|
46
|
+
git('log --pretty=format:%H').strip.split("\n").each(&block)
|
47
|
+
end
|
48
|
+
|
45
49
|
def add_all
|
46
50
|
git('add -A')
|
47
51
|
end
|
@@ -68,10 +72,10 @@ class TmpRepo
|
|
68
72
|
|
69
73
|
def git(command)
|
70
74
|
in_repo do
|
71
|
-
output = `#{git_executable} #{command}`
|
75
|
+
output = `#{git_executable} #{command} 2>&1`
|
72
76
|
|
73
77
|
if $?.exitstatus != 0
|
74
|
-
raise GitError, output
|
78
|
+
raise GitError, output.strip
|
75
79
|
end
|
76
80
|
|
77
81
|
output
|
@@ -123,5 +127,5 @@ class TmpRepo
|
|
123
127
|
|
124
128
|
def create_status_hash
|
125
129
|
{ modified: [], deleted: [], new_file: [] }
|
126
|
-
end
|
130
|
+
end
|
127
131
|
end
|
data/lib/tmp-repo/version.rb
CHANGED
data/spec/tmp-repo_spec.rb
CHANGED
@@ -16,12 +16,6 @@ describe TmpRepo do
|
|
16
16
|
repo.unlink
|
17
17
|
end
|
18
18
|
|
19
|
-
def in_repo
|
20
|
-
Dir.chdir(repo.working_dir.to_s) do
|
21
|
-
yield
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
19
|
describe '#initialize' do
|
26
20
|
it 'should initialize the repository' do
|
27
21
|
expect(repo.working_dir.join('.git')).to exist
|
@@ -57,12 +51,29 @@ describe TmpRepo do
|
|
57
51
|
end
|
58
52
|
end
|
59
53
|
|
54
|
+
describe '#each_commit_id' do
|
55
|
+
it 'yields commit ids one at a time' do
|
56
|
+
repo.create_file('foo.txt') { |f| f.write('foobar') }
|
57
|
+
repo.add_all
|
58
|
+
repo.commit('first commit')
|
59
|
+
|
60
|
+
repo.create_file('bar.txt') { |f| f.write('baz') }
|
61
|
+
repo.add_all
|
62
|
+
repo.commit('second commit')
|
63
|
+
|
64
|
+
first_id = repo.git('rev-parse HEAD').strip
|
65
|
+
second_id = repo.git('rev-parse HEAD~1').strip
|
66
|
+
|
67
|
+
expect(repo.each_commit_id.to_a).to eq([first_id, second_id])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
60
71
|
describe '#add_all' do
|
61
72
|
it 'stages all files' do
|
62
73
|
repo.create_file('foo.txt') { |f| f.write('foobar') }
|
63
74
|
repo.add_all
|
64
75
|
|
65
|
-
in_repo do
|
76
|
+
repo.in_repo do
|
66
77
|
expect(`git status`).to match(/new file:[\s]+foo\.txt/)
|
67
78
|
end
|
68
79
|
end
|
@@ -74,7 +85,7 @@ describe TmpRepo do
|
|
74
85
|
repo.add_all
|
75
86
|
repo.commit('Committing foobar')
|
76
87
|
|
77
|
-
in_repo do
|
88
|
+
repo.in_repo do
|
78
89
|
expect(`git log`).to match(/Committing foobar/)
|
79
90
|
expect(`git show --name-only HEAD`).to include('foo.txt')
|
80
91
|
end
|
@@ -93,14 +104,14 @@ describe TmpRepo do
|
|
93
104
|
|
94
105
|
describe '#checkout' do
|
95
106
|
it 'checks out the given branch' do
|
96
|
-
in_repo do
|
107
|
+
repo.in_repo do
|
97
108
|
`git checkout -b my_branch && git checkout master`
|
98
109
|
expect(`git rev-parse --abbrev-ref HEAD`.strip).to eq('master')
|
99
110
|
end
|
100
111
|
|
101
112
|
repo.checkout('my_branch')
|
102
113
|
|
103
|
-
in_repo do
|
114
|
+
repo.in_repo do
|
104
115
|
expect(`git rev-parse --abbrev-ref HEAD`.strip).to eq('my_branch')
|
105
116
|
end
|
106
117
|
end
|
@@ -110,7 +121,7 @@ describe TmpRepo do
|
|
110
121
|
it 'creates a new branch' do
|
111
122
|
repo.create_branch('new_branch')
|
112
123
|
|
113
|
-
in_repo do
|
124
|
+
repo.in_repo do
|
114
125
|
expect(`git branch`).to include('new_branch')
|
115
126
|
end
|
116
127
|
end
|
@@ -118,7 +129,7 @@ describe TmpRepo do
|
|
118
129
|
|
119
130
|
describe '#current_branch' do
|
120
131
|
it 'returns the current branch name' do
|
121
|
-
in_repo { `git checkout -b cool_branch` }
|
132
|
+
repo.in_repo { `git checkout -b cool_branch` }
|
122
133
|
expect(repo.current_branch).to eq('cool_branch')
|
123
134
|
end
|
124
135
|
end
|
@@ -145,7 +156,7 @@ describe TmpRepo do
|
|
145
156
|
end
|
146
157
|
|
147
158
|
it 'shows modified files' do
|
148
|
-
in_repo do
|
159
|
+
repo.in_repo do
|
149
160
|
File.open('foo.txt', 'w+') do |f|
|
150
161
|
f.write("\nI'm a change!")
|
151
162
|
end
|
@@ -159,7 +170,7 @@ describe TmpRepo do
|
|
159
170
|
end
|
160
171
|
|
161
172
|
it 'shows deleted files' do
|
162
|
-
in_repo do
|
173
|
+
repo.in_repo do
|
163
174
|
File.unlink('foo.txt')
|
164
175
|
repo.add_all
|
165
176
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tmp-repo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Dutro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Creates and manages a git repository in the operating system's temporary
|
14
14
|
directory. Useful for running git operations in tests.
|
@@ -36,19 +36,20 @@ require_paths:
|
|
36
36
|
- lib
|
37
37
|
required_ruby_version: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- -
|
44
|
+
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
47
|
requirements: []
|
48
48
|
rubyforge_project:
|
49
|
-
rubygems_version: 2.2.
|
49
|
+
rubygems_version: 2.2.3
|
50
50
|
signing_key:
|
51
51
|
specification_version: 4
|
52
52
|
summary: Creates and manages a git repository in the operating system's temporary
|
53
53
|
directory. Useful for running git operations in tests.
|
54
54
|
test_files: []
|
55
|
+
has_rdoc: true
|