promptula 0.0.4 → 0.0.5

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.
@@ -1,3 +1,3 @@
1
1
  module Promptula
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/promptula.rb CHANGED
@@ -6,6 +6,8 @@ module Promptula
6
6
  PATH_SEPARATOR = '/'
7
7
  BACKGROUND = "3a3a3a"
8
8
  GLYPH = "\u2733"
9
+ PULL_ARROW = "\u2798"
10
+ PUSH_ARROW = "\u279A"
9
11
 
10
12
  def self.cwd()
11
13
  current = Dir.pwd
@@ -25,14 +27,25 @@ module Promptula
25
27
  branch = line.sub('*', '').chomp
26
28
  end
27
29
  end
28
- status = `git status --porcelain 2>/dev/null`
30
+ remote = `git config branch.#{branch}.remote`.strip
31
+ status = `git status --ignore-submodules --porcelain 2>/dev/null`
29
32
  untracked = (status.match('\?\?') or '').size > 0 ? " #{GLYPH}" : ''
30
33
  dirty = status.size > 0
31
34
  background = dirty ? :red : :green
35
+ push_pull = `git rev-list --left-right remotes/#{remote}/#{branch}...HEAD`.split("\n")
36
+ to_push = (push_pull.select {|m| m.start_with? '>'}).length
37
+ to_pull = (push_pull.select {|m| m.start_with? '<'}).length
32
38
 
33
- SEPARATOR.foreground(background).background(BACKGROUND).inverse +
34
- "#{branch}#{untracked} ".background(background) +
35
- SEPARATOR.foreground(background).reset()
39
+ prompt = SEPARATOR.foreground(background).background(BACKGROUND).inverse
40
+ prompt += "#{branch}#{untracked} ".background(background)
41
+ if to_pull > 0
42
+ prompt += "#{PULL_ARROW}#{to_pull} ".background(background)
43
+ end
44
+ if to_push > 0
45
+ prompt += "#{PUSH_ARROW}#{to_push} ".background(background)
46
+ end
47
+ prompt += SEPARATOR.foreground(background).reset()
48
+ prompt
36
49
  end
37
50
 
38
51
  def self.prompt()
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: promptula
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-04 00:00:00.000000000 Z
12
+ date: 2012-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: trollop