augit 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2309674756759ab5ecec61613fc5ee70ef94a7e1
4
- data.tar.gz: 4076dc8852e2b58bedfde0a1e28dd0d60927ed08
3
+ metadata.gz: abcbcda785918c9b50ce54c9539efd1762cfcd73
4
+ data.tar.gz: 635648ceeb5d05925a9eeee4cd9ecad51fb43f77
5
5
  SHA512:
6
- metadata.gz: 4673ad51463400f89d6695281a2ad96cc0ea96548122e16cf8928f7cca666952f961b7729855070b3a7080a022ef40f30e5efd18f3829637f839272f07f187c3
7
- data.tar.gz: 9cf0807546cc59e07937784f8cbb1f01e5fdb70ecb0643e184a6b827331926e4e08d275e8377dbb895e36841364735bc8012f60075ec350be4fc5258449f181a
6
+ metadata.gz: 8266d58311c621693ec87de01126477d5fa57408888c310d778389bdd0307da57720b10e8ab39b7f7e2b3db86cf230122d2b886cf1551847530ef534579657a7
7
+ data.tar.gz: fe95058d6ffd844e2281a4fef0200f9b13954ab35168912ebfdb80eb9097bc86d5b7f9dabeb7459f01a331fbecee9a083dd959997cec588aedc7ee93b6a5838f
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- augit (0.0.1)
4
+ augit (0.0.2)
5
5
  actionview
6
6
  colorize
7
7
  highline
data/README.md CHANGED
@@ -12,10 +12,14 @@ $ gem install augit
12
12
 
13
13
  Augit will inspect your repository and evaluate the age and diffs of all remote and local branches.
14
14
 
15
+ cd /path/to/my/git/repo
16
+ augit audit
17
+
18
+ ![augit](http://i.imgur.com/73TrMeN.png)
15
19
 
16
20
  It will display all the remote branches that have been merged into master and give you the option of removing all of them in one go.
17
21
 
18
- Augit will then iterate through all unmerged branches one by one and give you the age, author and files changed. It will also print a link to a compare page on Github.
22
+ Augit will then iterate through all unmerged branches one by one and give you the age, author and files changed. It will also print a link to a compare page on Github. This is useful when using iTerm to cmd+click the link to open a diff.
19
23
 
20
24
  ## Contributing
21
25
 
data/bin/augit CHANGED
@@ -4,16 +4,22 @@ require 'augit'
4
4
 
5
5
  module Augit
6
6
  class Command < Thor
7
+
7
8
  desc "audit", "Audit the current directory"
9
+ method_option(:regexp, {
10
+ aliases: '-e',
11
+ desc: 'Only consider branches matching the provided regular expression'
12
+ })
13
+ method_option(:status, {
14
+ aliases: '-s',
15
+ desc: 'Show the statuses of the specified git branches'
16
+ })
17
+
8
18
  def audit
9
- Augit.audit
19
+ Augit.audit(options)
10
20
  end
21
+ default_task :audit
11
22
 
12
- private
13
-
14
- def directory
15
- `pwd`.rstrip
16
- end
17
23
  end
18
24
  end
19
25
 
@@ -7,6 +7,7 @@ module Augit
7
7
  autoload :Presenter, 'augit/presenter'
8
8
 
9
9
  def self.audit(options = {})
10
- Augit::Inspector.new.list
10
+ inspector = Augit::Inspector.new(options)
11
+ options[:status] ? inspector.status : inspector.list
11
12
  end
12
13
  end
@@ -1,7 +1,16 @@
1
1
  module Augit
2
2
  class Branch
3
+ include ::ActionView::Helpers::DateHelper
4
+
3
5
  attr_reader :name, :author, :origin, :commits, :age
4
6
 
7
+ CHANGE_MAP = [
8
+ { name: 'commit', regex: /^commit\s(.*)/ },
9
+ { name: 'author', regex: /^Author:\s(.*)\s</ },
10
+ { name: 'timestamp', regex: /^Date:\s*(.*)$/ },
11
+ { name: 'file', regex: /^:.*\s(.*)/ }
12
+ ]
13
+
5
14
  def initialize(name, origin)
6
15
  @name = name
7
16
  @origin = origin
@@ -31,7 +40,7 @@ module Augit
31
40
  changes.each do |line|
32
41
  next if line.nil? || line == ''
33
42
 
34
- checks.each do |check|
43
+ CHANGE_MAP.each do |check|
35
44
  value = line.match(check[:regex])
36
45
  next if value.nil?
37
46
 
@@ -54,12 +63,5 @@ module Augit
54
63
  def changes
55
64
  `git whatchanged --abbrev-commit master.. origin/#{name}`.split("\n")
56
65
  end
57
-
58
- def checks
59
- [{ name: 'commit', regex: /^commit\s(.*)/ },
60
- { name: 'author', regex: /^Author:\s(.*)\s</ },
61
- { name: 'timestamp', regex: /^Date:\s*(.*)$/ },
62
- { name: 'file', regex: /^:.*\s(.*)/ }]
63
- end
64
66
  end
65
67
  end
@@ -8,14 +8,13 @@ module Augit
8
8
  include ::ActionView::Helpers::TextHelper
9
9
  attr_reader :term, :origin, :branches, :merged, :unmerged, :repo
10
10
 
11
- def initialize(term = nil)
12
- @term = term
13
-
14
- @repo = Augit::Repo.new
11
+ def initialize(options = {})
12
+ @repo = Augit::Repo.new(options)
15
13
  @origin = repo.origin
16
14
  @branches = repo.branch_names
17
15
  @merged = repo.merged_branches
18
16
  @unmerged = branches - merged
17
+ @regexp = options[:regexp]
19
18
  end
20
19
 
21
20
  def list
@@ -35,6 +34,22 @@ module Augit
35
34
  end
36
35
  end
37
36
 
37
+ def section_message(data, filter)
38
+ filter = @regexp ? "matching /#{@regexp}/ " : ''
39
+ branches = pluralize(data.length, 'branch')
40
+ body = 'merged into master'
41
+ message = "#{branches} #{filter}#{body}"
42
+ data.any? ? "#{message}:" : message
43
+ end
44
+
45
+ def status
46
+ puts section_message(merged, @regexp).green
47
+ puts " #{merged.join("\n ")}"
48
+
49
+ puts section_message(unmerged, @regexp).red
50
+ puts " #{unmerged.join("\n ")}"
51
+ end
52
+
38
53
  def prompt(message)
39
54
  choice = ask("#{message} |(y)es, (n)o, (q)uit|".cyan)
40
55
  choice.strip.downcase.to_sym
@@ -1,7 +1,9 @@
1
1
  module Augit
2
2
  class Repo
3
- def initialize
4
-
3
+ attr_reader :regexp
4
+
5
+ def initialize(options = {})
6
+ @regexp = options[:regexp]
5
7
  end
6
8
 
7
9
  def origin
@@ -20,7 +22,8 @@ module Augit
20
22
  private
21
23
 
22
24
  def sanitize_string
23
- "grep -v master | sed \"s/ *origin\\///\" | sed \"s/ *tddium\\///\""
25
+ sanitize = "grep -v master | sed \"s/ *origin\\///\" | sed \"s/ *tddium\\///\""
26
+ regexp.nil? ? sanitize : "grep #{regexp} | #{sanitize}"
24
27
  end
25
28
  end
26
29
  end
@@ -1,3 +1,3 @@
1
1
  module Augit
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: augit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Werner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-07 00:00:00.000000000 Z
11
+ date: 2015-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -102,6 +102,7 @@ executables:
102
102
  extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
+ - ".gitignore"
105
106
  - Gemfile
106
107
  - Gemfile.lock
107
108
  - LICENSE.txt