git-status-all 1.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5871909417de7afdf95dd144953e66831b183f1c
4
+ data.tar.gz: 151cf64c2bfd277cab0c370e6eb65eafba36f4b7
5
+ SHA512:
6
+ metadata.gz: '08fba0c793293dd46eb1faae87cd27f087252b75ed86cf52e5e50e5136cda732528f462c09cc88217cc243792ea770e3025c88c4e2b4406f94b5da5bf45e72f2'
7
+ data.tar.gz: d7b3e91be2aecd062ae2912aa1cf29da698f1b93822de3bc214ece1230b58856a614dfb829ca370ce0caf1adb97fbe979271d36be04717b333ade60fd31fbe9f
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg/
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,26 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ git-status-all (1.1.0)
5
+ colorize
6
+ git (~> 1.3)
7
+ trollop
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ colorize (0.8.1)
13
+ git (1.3.0)
14
+ rake (10.5.0)
15
+ trollop (2.1.2)
16
+
17
+ PLATFORMS
18
+ ruby
19
+
20
+ DEPENDENCIES
21
+ bundler (~> 1.12)
22
+ git-status-all!
23
+ rake (~> 10.0)
24
+
25
+ BUNDLED WITH
26
+ 1.12.5
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Nathan Reed
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # git status-all
2
+
3
+ ## Installation
4
+
5
+ $ gem install git-status_all
6
+
7
+ ## Usage
8
+
9
+ Run the `status-all` subcommand inside a directory containing a number of repositories, and it will show the status for all of them.
10
+
11
+ $ git status-all
12
+
13
+ ![git-status terminal example](git-status.png)
14
+
15
+ Often you want to fetch from all the remotes for each repository first to see if there are any upstream changes. Use the `--fetch` or `-f` option to do this.
16
+
17
+ $ git status-all --fetch
18
+
19
+ It is also possible to look in a particular path instead of the current directory
20
+
21
+ $ git status-all ~/dev/ios
22
+
23
+ ## License
24
+
25
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "git/status_all"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'git/status_all'
3
+ Git::StatusAll::App.new.main
data/git-status.png ADDED
Binary file
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'git/status_all/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "git-status-all"
8
+ spec.version = Git::StatusAll::VERSION
9
+ spec.authors = ["Nathan Reed"]
10
+ spec.email = ["reednj@gmail.com"]
11
+
12
+ spec.summary = %q{show the status of all the git repositories in a directory}
13
+ spec.homepage = "https://github.com/reednj/git-status-all"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.12"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+
24
+ spec.required_ruby_version = '>=1.9.3'
25
+ spec.add_dependency 'colorize'
26
+ spec.add_dependency 'trollop'
27
+ spec.add_dependency 'git', "~> 1.3"
28
+ end
@@ -0,0 +1,100 @@
1
+ require 'git'
2
+ require 'colorize'
3
+ require 'trollop'
4
+
5
+ require "git/status_all/version"
6
+ require "git/status_all/extensions"
7
+ require "git/status_all/git"
8
+
9
+ module Git
10
+ module StatusAll
11
+ class App
12
+ def main
13
+ # we want to disable the text coloring if we are printing to a
14
+ # file, or on a platform (like windows) that likely doesn't support
15
+ # the colors
16
+ String.disable_colorization = !$stdout.isatty
17
+
18
+ opts = Trollop::options do
19
+ version "git-status-all #{Git::StatusAll::VERSION} (c) 2016 @reednj (reednj@gmail.com)"
20
+ banner "Usage: git-status-all [options] [path]"
21
+ opt :fetch, "perform fetch for each repository before getting status", :default => false
22
+ end
23
+
24
+ dev_dir = ARGV.last || '.'
25
+ repo_paths = Dir.entries(dev_dir).
26
+ map {|p| { :name => p, :path => File.expand_path(p, dev_dir) } }.
27
+ select { |p| Git.repo? p[:path] }
28
+
29
+ repo_paths.each do |p|
30
+ name = p[:name]
31
+
32
+ begin
33
+ g = Git.open p[:path]
34
+
35
+ if opts[:fetch]
36
+ print "#{name}".right_align("[#{"fetching...".yellow}]") + "\r"
37
+
38
+ if !g.remotes.empty?
39
+ remote = g.remotes.select{|r| r.name.downcase == 'origin' }.first || g.remotes.first
40
+ g.fetch remote
41
+ end
42
+ end
43
+
44
+ s = file_status(g)
45
+ r = remote_status(g)
46
+ s = " #{s} ".black.on_yellow unless s.empty?
47
+ n = s.empty? ? name : name.yellow
48
+ puts "#{n}".pad_to_col(24).append(s).right_align("#{r} [#{g.branches.current.to_s.blue}]")
49
+ rescue => e
50
+ if e.to_s.include? "ambiguous argument 'HEAD'"
51
+ err ='ERROR: NO HEAD'
52
+ else
53
+ err ='ERROR'
54
+ end
55
+
56
+ puts "#{name}".right_align("[#{err}]".red)
57
+ puts e.to_s if err == 'ERROR'
58
+ end
59
+ end
60
+
61
+ end
62
+
63
+ def file_status(g)
64
+ result = ""
65
+ result += "A#{g.status.added.length}" if g.status.added.length > 0
66
+ result += "D#{g.status.deleted.length}" if g.status.deleted.length > 0
67
+ result += "M#{g.status.changed.length}" if g.status.changed.length > 0
68
+ result += "U#{g.status.untracked.length}" if g.status.untracked.length > 0
69
+ return result
70
+ end
71
+
72
+ def remote_status(g)
73
+ if g.remotes.empty?
74
+ return "no remotes".black.on_red
75
+ end
76
+
77
+ if g.remotes.select{|r| r.name.downcase == 'origin' }.empty?
78
+ return "no origin".black.on_yellow
79
+ end
80
+
81
+ if !g.branches[:master].up_to_date?
82
+ b = g.branches[:master]
83
+
84
+ s = ''
85
+ s += "#{b.behind_count}\u2193" if b.behind_count > 0
86
+ s += "#{b.ahead_count}\u2191" if b.ahead_count > 0
87
+
88
+ return s.green
89
+ end
90
+
91
+ return ''
92
+ end
93
+
94
+ def term_width
95
+ @term_width ||= `tput cols`.to_i
96
+ end
97
+
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,23 @@
1
+
2
+
3
+ class String
4
+ def append(s)
5
+ self + s
6
+ end
7
+
8
+ def pad_to_col(n)
9
+ pad_amount = n - self.uncolorize.length
10
+ return " " + s if pad_amount < 0
11
+ return self + (" " * pad_amount)
12
+ end
13
+
14
+ def right_align(s)
15
+ pad_amount = self._term_width - self.uncolorize.length - s.uncolorize.length
16
+ return " " + s if pad_amount < 0
17
+ return self + (" " * pad_amount) + s
18
+ end
19
+
20
+ def _term_width
21
+ @term_width ||= `tput cols`.to_i
22
+ end
23
+ end
@@ -0,0 +1,52 @@
1
+ module Git
2
+ def self.repo? path
3
+ begin
4
+ self.open path
5
+ return true
6
+ rescue
7
+ return false
8
+ end
9
+ end
10
+
11
+ class Branches
12
+ def current
13
+ select{ |b| b.current? }.first
14
+ end
15
+ end
16
+
17
+ class Branch
18
+ def current?
19
+ current
20
+ end
21
+
22
+ def up_to_date?
23
+ ahead_count == 0 && behind_count == 0
24
+ end
25
+
26
+ def ahead
27
+ origin = self.remotes(:origin)
28
+ return [] if origin.nil?
29
+ @base.log.between(origin.full, self.name)
30
+ end
31
+
32
+ def behind
33
+ origin = self.remotes(:origin)
34
+ return [] if origin.nil?
35
+ @base.log.between(self.name, origin.full)
36
+ end
37
+
38
+ def ahead_count
39
+ @ahead_count ||= ahead.count
40
+ end
41
+
42
+ def behind_count
43
+ @behind_count ||= behind.count
44
+ end
45
+
46
+ def remotes(remote_name = nil)
47
+ result = @base.branches.remote.select{|b| b.name == self.name }
48
+ return result.select{|b| b.full.include? remote_name.to_s }.first unless remote_name.nil?
49
+ return result
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,5 @@
1
+ module Git
2
+ module StatusAll
3
+ VERSION = "1.1.0"
4
+ end
5
+ end
data/status-all-test ADDED
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ bundle exec exe/git-status-all "$@"
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git-status-all
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nathan Reed
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-12-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: colorize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: trollop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: git
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ description:
84
+ email:
85
+ - reednj@gmail.com
86
+ executables:
87
+ - git-status-all
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - exe/git-status-all
100
+ - git-status.png
101
+ - git-status_all.gemspec
102
+ - lib/git/status_all.rb
103
+ - lib/git/status_all/extensions.rb
104
+ - lib/git/status_all/git.rb
105
+ - lib/git/status_all/version.rb
106
+ - status-all-test
107
+ homepage: https://github.com/reednj/git-status-all
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: 1.9.3
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.6.6
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: show the status of all the git repositories in a directory
131
+ test_files: []