asgit 0.0.4 → 0.0.7

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
  SHA1:
3
- metadata.gz: cc550b94030a3e6bb0430a2880678522c6356cf2
4
- data.tar.gz: cfa580b8bd83ac2a8b2f42abecb6ae6cb2d1d080
3
+ metadata.gz: 2d0990c0d9e5711c07321399d20e43a162d9abdc
4
+ data.tar.gz: d835ab6bc39cd6b1fce0c1feb2e84d0a666a70d0
5
5
  SHA512:
6
- metadata.gz: d30037bfd83bffebb313c21ed15c826575fb24d469ff9378ab7a153f0bad396f1818a6aa54dc252e7639fd92c0aa0593f743057aa1e40fb6f69ebfa6481970d4
7
- data.tar.gz: f32403eee3d40b47cf9ca4eacb67aa6f2259b18f88168db4ea352bc3e5389aa33914b20132ee84a16ba86e1e00685ea32b7a806ac14526e252bd6b5c6ca87635
6
+ metadata.gz: 9dfcd2bfc863483514cd09d289a1549b9eac37271d3f633e564eae1c152a6e91cf2fc645515f3f47862a23d960bb7be52b1637c48517ae10206d8985ccbc25da
7
+ data.tar.gz: 9683eaadfaad38cf876b4dd41200411e30b87836a962edc9ea45607347f99fd92a981d7bf240d5699f4697ce0c16045cef94e1432d797ac0ff0ebc02a2b8e049
data/lib/asgit/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Asgit
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.7"
3
3
  end
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.include? "nothing to commit"
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.gsub(/^refs\/heads\//, '')
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 && stderr.include?( "Everything up-to-date" )
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
@@ -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 be_false
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 be_false
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 be_true
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.fake_stdout "# On branch master\n" +
8
- "nothing to commit, working directory clean" do
9
- Asgit.working_tree_clean?.should be_true
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 "# On branch master\n" +
14
- "# Untracked files:\n" +
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.fake_stdout "refs/heads/master" do
27
- Asgit.current_branch.should == "master"
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.should == "12345"
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.fake_stderr "Everything up-to-date" do
43
- Asgit.remote_up_to_date?.should be_true
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.fake_stderr "To git@github.com:mailchimp/statistrano.git\n" +
48
- "fbe7c67..3cf2934 HEAD -> master" do
49
- Asgit.remote_up_to_date?.should be_false
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
@@ -19,7 +19,7 @@ module Asgit
19
19
  def patched_run command, &block
20
20
  if @shell_out || @shell_err
21
21
  yield @shell_out if block_given?
22
- [ true, @shell_out, @shell_err ]
22
+ [ true, @shell_out || '', @shell_err || '' ]
23
23
  else
24
24
  system_run command, &block
25
25
  end
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
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-01 00:00:00.000000000 Z
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.0.5
53
+ rubygems_version: 2.1.11
54
54
  signing_key:
55
55
  specification_version: 4
56
56
  summary: A simple query interface for git