asgit 0.0.4 → 0.0.7
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/lib/asgit/version.rb +1 -1
- data/lib/asgit.rb +6 -6
- data/spec/asgit/config_spec.rb +3 -3
- data/spec/asgit_spec.rb +19 -18
- data/spec/support/fake_stdout.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d0990c0d9e5711c07321399d20e43a162d9abdc
|
4
|
+
data.tar.gz: d835ab6bc39cd6b1fce0c1feb2e84d0a666a70d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dfcd2bfc863483514cd09d289a1549b9eac37271d3f633e564eae1c152a6e91cf2fc645515f3f47862a23d960bb7be52b1637c48517ae10206d8985ccbc25da
|
7
|
+
data.tar.gz: 9683eaadfaad38cf876b4dd41200411e30b87836a962edc9ea45607347f99fd92a981d7bf240d5699f4697ce0c16045cef94e1432d797ac0ff0ebc02a2b8e049
|
data/lib/asgit/version.rb
CHANGED
data/lib/asgit.rb
CHANGED
@@ -9,16 +9,16 @@ module Asgit
|
|
9
9
|
# Check if working tree is clean
|
10
10
|
# @return [Boolean] true if branch is clean
|
11
11
|
def working_tree_clean?
|
12
|
-
Shell.run "git status" do |output|
|
13
|
-
return output.
|
12
|
+
Shell.run "git status --porcelain" do |output|
|
13
|
+
return output.empty?
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
# Get current git branch based on exec directory
|
18
18
|
# @return [String] the current checked out branch
|
19
19
|
def current_branch
|
20
|
-
Shell.run "git symbolic-ref HEAD" do |output|
|
21
|
-
return output.strip
|
20
|
+
Shell.run "git symbolic-ref HEAD --short" do |output|
|
21
|
+
return output.strip
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -33,8 +33,8 @@ module Asgit
|
|
33
33
|
# Check if branch is in sync with remote
|
34
34
|
# @return [Boolean]
|
35
35
|
def remote_up_to_date?
|
36
|
-
status, stdout, stderr = Shell.run "git push --dry-run"
|
37
|
-
return status &&
|
36
|
+
status, stdout, stderr = Shell.run "git push --dry-run --porcelain"
|
37
|
+
return status && stdout.match(/#{current_branch}\s+?\[up\sto\sdate\]/)
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|
data/spec/asgit/config_spec.rb
CHANGED
@@ -51,7 +51,7 @@ describe Asgit::Config do
|
|
51
51
|
|
52
52
|
describe "::configured?" do
|
53
53
|
it "returns false if configuration hasn't been set" do
|
54
|
-
expect( Asgit.configured? ).to
|
54
|
+
expect( Asgit.configured? ).to be_falsy
|
55
55
|
end
|
56
56
|
|
57
57
|
it "returns false if config is partially set" do
|
@@ -59,7 +59,7 @@ describe Asgit::Config do
|
|
59
59
|
c.project = 'foo'
|
60
60
|
end
|
61
61
|
|
62
|
-
expect( Asgit.configured? ).to
|
62
|
+
expect( Asgit.configured? ).to be_falsy
|
63
63
|
end
|
64
64
|
|
65
65
|
it "returns true if configuration has been set" do
|
@@ -69,7 +69,7 @@ describe Asgit::Config do
|
|
69
69
|
c.service = :github
|
70
70
|
end
|
71
71
|
|
72
|
-
expect( Asgit.configured? ).to
|
72
|
+
expect( Asgit.configured? ).to be_truthy
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
data/spec/asgit_spec.rb
CHANGED
@@ -4,27 +4,23 @@ describe Asgit do
|
|
4
4
|
|
5
5
|
describe "::working_tree_clean?" do
|
6
6
|
it "is true when nothing to commit" do
|
7
|
-
Asgit::Shell.
|
8
|
-
|
9
|
-
Asgit.working_tree_clean
|
7
|
+
expect( Asgit::Shell ).to receive(:run).with('git status --porcelain').and_call_original
|
8
|
+
Asgit::Shell.fake_stdout "" do
|
9
|
+
expect( Asgit.working_tree_clean? ).to be_truthy
|
10
10
|
end
|
11
11
|
end
|
12
12
|
it "is false when tree isn't clean" do
|
13
|
-
Asgit::Shell.fake_stdout "
|
14
|
-
|
15
|
-
"# (use \"git add <file>...\" to include in what will be committed)\n" +
|
16
|
-
"#\n" +
|
17
|
-
"# foo\n" +
|
18
|
-
"nothing added to commit but untracked files present (use \"git add\" to track)\n" do
|
19
|
-
Asgit.working_tree_clean?.should be_false
|
13
|
+
Asgit::Shell.fake_stdout "M changelog.md\n" do
|
14
|
+
expect( Asgit.working_tree_clean? ).to be_falsy
|
20
15
|
end
|
21
16
|
end
|
22
17
|
end
|
23
18
|
|
24
19
|
describe "::current_branch" do
|
25
20
|
it "returns master when on master" do
|
26
|
-
Asgit::Shell.
|
27
|
-
|
21
|
+
expect( Asgit::Shell ).to receive(:run).with('git symbolic-ref HEAD --short').and_call_original
|
22
|
+
Asgit::Shell.fake_stdout "master\n" do
|
23
|
+
expect( Asgit.current_branch ).to eq "master"
|
28
24
|
end
|
29
25
|
end
|
30
26
|
end
|
@@ -32,21 +28,26 @@ describe Asgit do
|
|
32
28
|
describe "::current_commit" do
|
33
29
|
it "returns current commit" do
|
34
30
|
Asgit::Shell.fake_stdout "12345" do
|
35
|
-
Asgit.current_commit.
|
31
|
+
expect( Asgit.current_commit ).to eq "12345"
|
36
32
|
end
|
37
33
|
end
|
38
34
|
end
|
39
35
|
|
40
36
|
describe "::remote_up_to_date?" do
|
41
37
|
it "returns true if remote is current" do
|
42
|
-
Asgit::Shell.
|
43
|
-
|
38
|
+
Asgit::Shell.fake_stdout "To git@github.com:stevenosloan/asgit.git\n" +
|
39
|
+
"=\tHEAD:refs/heads/master\t[up to date]\n" +
|
40
|
+
"Done\n" do
|
41
|
+
allow( Asgit ).to receive(:current_branch).and_return("master")
|
42
|
+
expect( Asgit.remote_up_to_date? ).to be_truthy
|
44
43
|
end
|
45
44
|
end
|
46
45
|
it "returns false if remote is out of sync" do
|
47
|
-
Asgit::Shell.
|
48
|
-
"
|
49
|
-
|
46
|
+
Asgit::Shell.fake_stdout "To git@github.com:stevenosloan/asgit.git\n" +
|
47
|
+
"\tHEAD:refs/heads/master\t5871eb5..0ce6c7f\n" +
|
48
|
+
"Done\n" do
|
49
|
+
allow( Asgit ).to receive(:current_branch).and_return("master")
|
50
|
+
expect( Asgit.remote_up_to_date? ).to be_falsy
|
50
51
|
end
|
51
52
|
end
|
52
53
|
end
|
data/spec/support/fake_stdout.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asgit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Sloan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ' A simple query interface for git. '
|
14
14
|
email:
|
@@ -50,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
50
|
version: '0'
|
51
51
|
requirements: []
|
52
52
|
rubyforge_project:
|
53
|
-
rubygems_version: 2.
|
53
|
+
rubygems_version: 2.1.11
|
54
54
|
signing_key:
|
55
55
|
specification_version: 4
|
56
56
|
summary: A simple query interface for git
|