insync 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +37 -0
- data/Rakefile +1 -0
- data/bin/insync +28 -0
- data/insync.gemspec +24 -0
- data/lib/insync.rb +81 -0
- data/lib/insync/version.rb +3 -0
- metadata +90 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011, George Drummond, AccountsApp Ltd
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Insync
|
2
|
+
|
3
|
+
A simple tool to let you know which git repositories in a folder are either behind, ahead or out of sync with the origin/master}
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
gem install insync
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
In your directory run the command
|
12
|
+
|
13
|
+
insync
|
14
|
+
|
15
|
+
## License
|
16
|
+
|
17
|
+
Copyright (c) 2011, George Drummond, AccountsApp Ltd
|
18
|
+
|
19
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
20
|
+
a copy of this software and associated documentation files (the
|
21
|
+
"Software"), to deal in the Software without restriction, including
|
22
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
23
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
24
|
+
permit persons to whom the Software is furnished to do so, subject to
|
25
|
+
the following conditions:
|
26
|
+
|
27
|
+
The above copyright notice and this permission notice shall be
|
28
|
+
included in all copies or substantial portions of the Software.
|
29
|
+
|
30
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
31
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
32
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
33
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
34
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
35
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
36
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
37
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/insync
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'cli-colorize'
|
4
|
+
require 'insync'
|
5
|
+
|
6
|
+
include CLIColorize
|
7
|
+
|
8
|
+
if ARGV[0]
|
9
|
+
about = <<EOL
|
10
|
+
|
11
|
+
Insync v#{Insync::VERSION}
|
12
|
+
====================
|
13
|
+
A simple tool to let you know which git repositories
|
14
|
+
in a folder are either behind, ahead or out of sync
|
15
|
+
with the origin/master.
|
16
|
+
|
17
|
+
Usage
|
18
|
+
====================
|
19
|
+
Just navigate to the folder and type the command `insync`.
|
20
|
+
|
21
|
+
==> http://github.com/georgedrummond/insync
|
22
|
+
|
23
|
+
EOL
|
24
|
+
puts colorize(about, :config => :bright)
|
25
|
+
else
|
26
|
+
current_directory = Dir.pwd
|
27
|
+
Insync::RepoWatch.new(current_directory).watch
|
28
|
+
end
|
data/insync.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "insync/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "insync"
|
7
|
+
s.version = Insync::VERSION
|
8
|
+
s.authors = ["George Drummond"]
|
9
|
+
s.email = ["george@accountsapp.com"]
|
10
|
+
s.homepage = "http://github.com/georgedrummond/insync"
|
11
|
+
s.summary = %q{A simple tool to let you know which git repositories in a folder are either behind, ahead or out of sync with the origin/master}
|
12
|
+
s.description = %q{A simple tool to let you know which git repositories in a folder are either behind, ahead or out of sync with the origin/master}
|
13
|
+
|
14
|
+
s.rubyforge_project = "insync"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_dependency "git"
|
22
|
+
s.add_dependency "grit"
|
23
|
+
s.add_dependency "cli-colorize"
|
24
|
+
end
|
data/lib/insync.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require "insync/version"
|
2
|
+
require 'grit'
|
3
|
+
require 'git'
|
4
|
+
require 'cli-colorize'
|
5
|
+
|
6
|
+
module Insync
|
7
|
+
class Repository
|
8
|
+
|
9
|
+
def initialize(path)
|
10
|
+
@path = path
|
11
|
+
@repo = Grit::Repo.new @path
|
12
|
+
@branch = @repo
|
13
|
+
end
|
14
|
+
|
15
|
+
def path
|
16
|
+
@path
|
17
|
+
end
|
18
|
+
|
19
|
+
def log
|
20
|
+
@branch.log
|
21
|
+
end
|
22
|
+
|
23
|
+
def remote_log
|
24
|
+
g = Git.open @path
|
25
|
+
g.fetch
|
26
|
+
@branch.log("origin/master")
|
27
|
+
end
|
28
|
+
|
29
|
+
def remote_origin_exists?
|
30
|
+
return @repo.remotes.any? { |remote| remote.name == "origin/master" }
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
class RepoWatch
|
36
|
+
include CLIColorize
|
37
|
+
|
38
|
+
def initialize(path)
|
39
|
+
@path = path
|
40
|
+
end
|
41
|
+
|
42
|
+
def watch
|
43
|
+
directory_entries = Dir.entries(@path)
|
44
|
+
dirs = directory_entries.find_all {|e| File.directory?(full_path_of e) && e =~ /^[^.]+/}
|
45
|
+
|
46
|
+
inspect_path(@path)
|
47
|
+
|
48
|
+
dirs.each do |dir_name|
|
49
|
+
dir = full_path_of dir_name
|
50
|
+
inspect_path(dir)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def inspect_path(path)
|
55
|
+
begin
|
56
|
+
repo = Repository.new path
|
57
|
+
if repo.remote_origin_exists?
|
58
|
+
local = repo.log
|
59
|
+
remote = repo.remote_log
|
60
|
+
if local.first.id != remote.first.id && local.count == remote.count
|
61
|
+
puts colorize("\n#{path}\n => Out of sync\n", { :foreground => :red, :config => :bright })
|
62
|
+
elsif local.count < remote.count
|
63
|
+
puts colorize("\n#{path}\n => Behind by #{remote.count-local.count} commits\n", { :foreground => :blue, :config => :bright })
|
64
|
+
elsif local.count > remote.count
|
65
|
+
puts colorize("\n#{path}\n => Ahead by #{local.count-remote.count} commits\n", { :foreground => :magenta, :config => :bright })
|
66
|
+
end
|
67
|
+
end
|
68
|
+
rescue
|
69
|
+
nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def full_path_of(file)
|
76
|
+
File.join(@path, file)
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: insync
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- George Drummond
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-10-28 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: git
|
16
|
+
requirement: &70238923514380 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70238923514380
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: grit
|
27
|
+
requirement: &70238923513900 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70238923513900
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: cli-colorize
|
38
|
+
requirement: &70238923510340 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70238923510340
|
47
|
+
description: A simple tool to let you know which git repositories in a folder are
|
48
|
+
either behind, ahead or out of sync with the origin/master
|
49
|
+
email:
|
50
|
+
- george@accountsapp.com
|
51
|
+
executables:
|
52
|
+
- insync
|
53
|
+
extensions: []
|
54
|
+
extra_rdoc_files: []
|
55
|
+
files:
|
56
|
+
- .gitignore
|
57
|
+
- Gemfile
|
58
|
+
- LICENSE
|
59
|
+
- README.md
|
60
|
+
- Rakefile
|
61
|
+
- bin/insync
|
62
|
+
- insync.gemspec
|
63
|
+
- lib/insync.rb
|
64
|
+
- lib/insync/version.rb
|
65
|
+
homepage: http://github.com/georgedrummond/insync
|
66
|
+
licenses: []
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project: insync
|
85
|
+
rubygems_version: 1.8.11
|
86
|
+
signing_key:
|
87
|
+
specification_version: 3
|
88
|
+
summary: A simple tool to let you know which git repositories in a folder are either
|
89
|
+
behind, ahead or out of sync with the origin/master
|
90
|
+
test_files: []
|