git_checker 0.0.1
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.
- data/.gitignore +6 -0
- data/Gemfile +4 -0
- data/README.markdown +50 -0
- data/Rakefile +1 -0
- data/bin/agck +16 -0
- data/bin/gck +13 -0
- data/git_checker.gemspec +20 -0
- data/lib/branch.rb +27 -0
- data/lib/git_checker/version.rb +3 -0
- data/lib/git_checker.rb +48 -0
- data/lib/message_printer.rb +24 -0
- data/lib/repository.rb +40 -0
- metadata +62 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
Git Checker
|
2
|
+
===========
|
3
|
+
screenshot: http://dl.dropbox.com/u/5847684/Screen%20shot%202011-06-30%20at%201.05.43%20PM.png
|
4
|
+
|
5
|
+
It is useful for keep an eye on your git repositories, what branch has been not merged yet, commits not in some branch and more.
|
6
|
+
|
7
|
+
"It's like a Test for your git"
|
8
|
+
|
9
|
+
Install:
|
10
|
+
--------
|
11
|
+
|
12
|
+
`gem install git_checker`
|
13
|
+
|
14
|
+
Usage:
|
15
|
+
------
|
16
|
+
|
17
|
+
Create a file with the extencion .gck.rb
|
18
|
+
`touch checkthis.gck.rb`
|
19
|
+
|
20
|
+
Add some checks in that file, like:
|
21
|
+
`
|
22
|
+
#checkthis.gck.rb
|
23
|
+
local = Repository.new
|
24
|
+
commits_not_in local.branches['master'], local
|
25
|
+
`
|
26
|
+
|
27
|
+
Then run the command:
|
28
|
+
`gck`
|
29
|
+
|
30
|
+
More:
|
31
|
+
-----
|
32
|
+
|
33
|
+
You can also ask for run task that you not always want, like this:
|
34
|
+
`
|
35
|
+
#checkthis.gck.rb
|
36
|
+
local= Repository.new
|
37
|
+
remote= Repository.new 'remote'
|
38
|
+
|
39
|
+
commits_not_in local.branches['master'], local
|
40
|
+
|
41
|
+
check_group "Check for branches not in Remote?" do
|
42
|
+
branches_not_in remote, local
|
43
|
+
end #>>> Check for branches not in Remote? [y/n]
|
44
|
+
`
|
45
|
+
|
46
|
+
You can skip this questions an run all with the command `agck`
|
47
|
+
|
48
|
+
Please:
|
49
|
+
-------
|
50
|
+
Feedback.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/agck
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'git_checker'
|
4
|
+
include GitChecker
|
5
|
+
|
6
|
+
def check_group question, &block
|
7
|
+
yield
|
8
|
+
end
|
9
|
+
|
10
|
+
checkers = Dir.entries(Dir.pwd).find_all do |f|
|
11
|
+
f.match /\.gck/
|
12
|
+
end
|
13
|
+
|
14
|
+
checkers.each do |ck|
|
15
|
+
eval File.read(ck)
|
16
|
+
end
|
data/bin/gck
ADDED
data/git_checker.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "git_checker/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "git_checker"
|
7
|
+
s.version = GitChecker::VERSION
|
8
|
+
s.authors = ["leizzer"]
|
9
|
+
s.email = ["lizzydw@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/leizzer/git_checker"
|
11
|
+
s.summary = %q{Keep an eye on your git repository}
|
12
|
+
s.description = %q{Using git_checker you can make scrips for perform checks over your git repositories easily }
|
13
|
+
|
14
|
+
s.rubyforge_project = "git_checker"
|
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
|
+
end
|
data/lib/branch.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
class Branch
|
2
|
+
|
3
|
+
attr_accessor :name, :repo
|
4
|
+
|
5
|
+
def initialize name, repo=nil
|
6
|
+
@name = name
|
7
|
+
@repo = repo
|
8
|
+
end
|
9
|
+
|
10
|
+
def merges_with word
|
11
|
+
log_merges.split.find_all { |merge| merge.include? word }
|
12
|
+
end
|
13
|
+
|
14
|
+
def log_merges
|
15
|
+
`git log #{full_repo_name @repo}#{@name} --merges`
|
16
|
+
end
|
17
|
+
|
18
|
+
def commits_not_merged_from branch
|
19
|
+
`git log --color #{full_repo_name @repo}#{@name}..#{full_repo_name(branch.repo)}#{branch.name}`
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def full_repo_name repo
|
25
|
+
"#{repo}/" if repo
|
26
|
+
end
|
27
|
+
end
|
data/lib/git_checker.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require_relative "git_checker/version"
|
2
|
+
require_relative 'message_printer'
|
3
|
+
require_relative 'repository'
|
4
|
+
require_relative 'branch'
|
5
|
+
|
6
|
+
module GitChecker
|
7
|
+
|
8
|
+
include MessagePrinter
|
9
|
+
|
10
|
+
def branches_not_in repo, from, ignore=[]
|
11
|
+
print_message "Branches in #{from.name.capitalize} not in #{repo.name.capitalize}"
|
12
|
+
puts repo.missing_branches(from.list_of_branches) - ignore
|
13
|
+
end
|
14
|
+
|
15
|
+
def branches_not_merged_in branch, from, ignore=[]
|
16
|
+
print_message "Branches not in #{branch.name.capitalize}"
|
17
|
+
branches = []
|
18
|
+
from.branches.values.each do |b|
|
19
|
+
unless ignore.include? b.name
|
20
|
+
branches << b.name if branch.merges_with(b.name).empty?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
puts branches
|
24
|
+
end
|
25
|
+
|
26
|
+
def commits_not_in branch, from, ignore=[]
|
27
|
+
print_message "Commits not in #{branch.name.capitalize}"
|
28
|
+
from.branches.each_value do |b|
|
29
|
+
unless ignore.include? b.name
|
30
|
+
log = branch.commits_not_merged_from b
|
31
|
+
unless log.empty?
|
32
|
+
print_message "#{b.name}: Commits not on #{branch.name.capitalize}", :color => "\e[31m", :pound => '+'
|
33
|
+
puts log
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
#You ask, you answer and you have
|
40
|
+
def check_group question, &block
|
41
|
+
print "\n>>> #{question} [y/n] "
|
42
|
+
answer = gets.strip
|
43
|
+
if answer == 'y'
|
44
|
+
yield
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module MessagePrinter
|
2
|
+
|
3
|
+
SCREEN_SIZE = 80
|
4
|
+
POUND = "#"
|
5
|
+
COLOR = "\e[36m"
|
6
|
+
|
7
|
+
def print_message(message, options = {})
|
8
|
+
puts format_message(message, options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def format_message(message, options = {})
|
12
|
+
|
13
|
+
message_size = message.size + 2
|
14
|
+
color = options.fetch(:color, COLOR)
|
15
|
+
pounds_count = ((SCREEN_SIZE - message_size ) / 2)
|
16
|
+
pounds = options.fetch(:pound, POUND) * pounds_count
|
17
|
+
|
18
|
+
pre = "\n\n\e[1m#{color}\e[7m#{pounds}#{message.size.odd? ? POUND : ''}"
|
19
|
+
post = "#{pounds}\e[m\e[m\e[m"
|
20
|
+
|
21
|
+
"#{pre} #{message} #{post}"
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/lib/repository.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
class Repository
|
2
|
+
|
3
|
+
attr_accessor :branches, :name
|
4
|
+
|
5
|
+
def initialize(repo = nil)
|
6
|
+
@name = repo || 'local'
|
7
|
+
collect_branches_from repo
|
8
|
+
end
|
9
|
+
|
10
|
+
def missing_branches branch_list
|
11
|
+
branch_list.find_all {|b| !list_of_branches.include? b }
|
12
|
+
end
|
13
|
+
|
14
|
+
def list_of_branches
|
15
|
+
@branches.keys
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def collect_branches_from repo
|
21
|
+
@branches = {}
|
22
|
+
list_branches(repo).each do |b|
|
23
|
+
@branches[b] = Branch.new b, repo
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def list_branches repo
|
28
|
+
if repo
|
29
|
+
branches = branch_name `git branch -r`.split, repo
|
30
|
+
else
|
31
|
+
branches = `git branch`.split
|
32
|
+
end
|
33
|
+
branches - ['*']
|
34
|
+
end
|
35
|
+
|
36
|
+
def branch_name list, repo
|
37
|
+
list.map { |b| b.sub "#{repo}/", '' }
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: git_checker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- leizzer
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-07-24 00:00:00.000000000 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
description: ! "Using git_checker you can make scrips for perform checks over your
|
16
|
+
git repositories easily\t"
|
17
|
+
email:
|
18
|
+
- lizzydw@gmail.com
|
19
|
+
executables:
|
20
|
+
- agck
|
21
|
+
- gck
|
22
|
+
extensions: []
|
23
|
+
extra_rdoc_files: []
|
24
|
+
files:
|
25
|
+
- .gitignore
|
26
|
+
- Gemfile
|
27
|
+
- README.markdown
|
28
|
+
- Rakefile
|
29
|
+
- bin/agck
|
30
|
+
- bin/gck
|
31
|
+
- git_checker.gemspec
|
32
|
+
- lib/branch.rb
|
33
|
+
- lib/git_checker.rb
|
34
|
+
- lib/git_checker/version.rb
|
35
|
+
- lib/message_printer.rb
|
36
|
+
- lib/repository.rb
|
37
|
+
has_rdoc: true
|
38
|
+
homepage: https://github.com/leizzer/git_checker
|
39
|
+
licenses: []
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubyforge_project: git_checker
|
58
|
+
rubygems_version: 1.6.2
|
59
|
+
signing_key:
|
60
|
+
specification_version: 3
|
61
|
+
summary: Keep an eye on your git repository
|
62
|
+
test_files: []
|