furi-git-prompt 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: bdd2a3245f4c931c64d1ea6a87be8f3f3b90d7e6
4
- data.tar.gz: 1df2e2d5a953a19f4c0b8238236befe7ab1a0e19
3
+ metadata.gz: f9e5ed6478cfdddcd30c864c75cb7c5d169e19b5
4
+ data.tar.gz: cb5d1cd5ae5721fcab7289b3718314e6ff8af253
5
5
  SHA512:
6
- metadata.gz: 93f45f74c2a13ce7000d76740a38ca391a9419dfda7b5f8e056d519cb4c87fc4bec86862b4c52fd8e7ed3014b698a15ff80a5127a1baae4ec3840a6f55d442b6
7
- data.tar.gz: fd0f30aa3373e50900a7651bdac1515dc920c9dd3ce65729d981c833b07d5e55038b438157d185f2bc92f23650d6e72e14ce164839373b0dbf2cca04336496fd
6
+ metadata.gz: 08e4a08dc195538bfeff736d80f58268f74db5636a054fcaab5a91b0c60a26f7e34ce4ce0f5e4676ad58a94cab7918ae43e43da184dc3dee00f5af01e850d1d3
7
+ data.tar.gz: b1eab1c25b2ae338ca4cfbf7892ab58139b081fb17b20ea1544aa5f0d0c9fe9f93d60b6552a4104942b8d9d222605798edd6e6c96b2f2fefa905625f956313af
data/lib/furi/git/git.rb CHANGED
@@ -6,6 +6,11 @@ class Git
6
6
  end
7
7
 
8
8
  def branch
9
- @git_system.git_branch
9
+ git_branch_match = @git_system.git_branch.match(/\* ([^\s.]*)/i)
10
+ if git_branch_match
11
+ git_branch_match.captures[0]
12
+ else
13
+ ''
14
+ end
10
15
  end
11
16
  end
@@ -1,5 +1,5 @@
1
1
  class GitSystemCall
2
2
  def git_branch
3
- %x(git branch)
3
+ %x(git branch 2> /dev/null)
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  module Furi
2
2
  module Git
3
3
  module Prompt
4
- VERSION = '0.0.4'
4
+ VERSION = '0.0.7'
5
5
  end
6
6
  end
7
7
  end
@@ -3,9 +3,33 @@ require 'rspec'
3
3
  require 'furi/git/git'
4
4
 
5
5
  describe Git do
6
-
7
- it 'show current branch name of a git repository' do
8
- GitSystemCall.any_instance.stub(:git_branch).and_return('master')
6
+ it 'shows the current branch name of a git repository' do
7
+ GitSystemCall.any_instance.stub(:git_branch).and_return('* master')
9
8
  Git.new.branch.should == 'master'
10
9
  end
10
+
11
+ context 'more than one git repository exist' do
12
+ it 'shows the current branch name of a git repository if branch is first item in list' do
13
+ GitSystemCall.any_instance.stub(:git_branch).and_return("* master\n sec branch\n third branch")
14
+ Git.new.branch.should == 'master'
15
+ end
16
+
17
+ it 'shows the current branch name of a git repository if branch is second item in list' do
18
+ GitSystemCall.any_instance.stub(:git_branch).and_return(" sec branch\n * master\n third branch")
19
+ Git.new.branch.should == 'master'
20
+ end
21
+
22
+ it 'shows the current branch name of a git repository if branch is last item in list' do
23
+ GitSystemCall.any_instance.stub(:git_branch).and_return(" sec branch\n third branch\n * master")
24
+ Git.new.branch.should == 'master'
25
+ end
26
+ end
27
+
28
+ context 'no git repository exist' do
29
+ it 'shows nothing' do
30
+ GitSystemCall.any_instance.stub(:git_branch).and_return("fatal: Not a git repository (or any of the parent directories): .git\n")
31
+ Git.new.branch.should be_empty
32
+ end
33
+ end
34
+
11
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: furi-git-prompt
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
  - Theo Pack