gitdia 0.0.1.pre
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/bin/gitdia +6 -0
- data/lib/gitdia.rb +102 -0
- metadata +48 -0
data/bin/gitdia
ADDED
data/lib/gitdia.rb
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
# available commands are:
|
|
4
|
+
# gita status
|
|
5
|
+
# gita add all
|
|
6
|
+
# gita commit "msg..."
|
|
7
|
+
|
|
8
|
+
require 'yaml'
|
|
9
|
+
|
|
10
|
+
class GitDia
|
|
11
|
+
|
|
12
|
+
attr :h_repos
|
|
13
|
+
attr :n_max_repo_len # formatting
|
|
14
|
+
|
|
15
|
+
# ----------------------------------------
|
|
16
|
+
def load_config()
|
|
17
|
+
s_config_file = File.join(Dir.home(), '.gitdia')
|
|
18
|
+
File.new(s_config_file, "w") unless File.exists?(s_config_file)
|
|
19
|
+
h_config = YAML.load_file(s_config_file)
|
|
20
|
+
|
|
21
|
+
raise "No 'repos' key found in config file. " if h_config.kind_of?(TrueClass) or h_config.kind_of?(FalseClass)
|
|
22
|
+
raise "No repo found in config file. " if !h_config.has_key?("repos") or h_config["repos"].empty?
|
|
23
|
+
|
|
24
|
+
@n_max_repo_len = 0
|
|
25
|
+
@h_repos = h_config["repos"]
|
|
26
|
+
@h_repos.each { |s_repo, s_repo_path|
|
|
27
|
+
@n_max_repo_len = [s_repo_path.length, @n_max_repo_len].max
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# ----------------------------------------
|
|
32
|
+
def git()
|
|
33
|
+
# looking for .gitdia file under user home
|
|
34
|
+
# create one if not exist
|
|
35
|
+
|
|
36
|
+
load_config()
|
|
37
|
+
|
|
38
|
+
# cmd
|
|
39
|
+
s_cmd = ''
|
|
40
|
+
s_cmd_name = ARGV[0]
|
|
41
|
+
s_cmd_opt = ARGV[1]
|
|
42
|
+
s_output = ""
|
|
43
|
+
b_block = nil
|
|
44
|
+
|
|
45
|
+
case s_cmd_name
|
|
46
|
+
when 'status'
|
|
47
|
+
s_cmd = 'git status --porcelain'
|
|
48
|
+
when 'add'
|
|
49
|
+
case s_cmd_opt
|
|
50
|
+
when 'all'
|
|
51
|
+
s_cmd = 'git add --all'
|
|
52
|
+
else
|
|
53
|
+
puts "to be implemented: #{s_cmd_opt}"
|
|
54
|
+
end
|
|
55
|
+
when 'commit'
|
|
56
|
+
|
|
57
|
+
b_block = Proc.new(){ |s_repo|
|
|
58
|
+
s_cmd = "git commit --porcelain" # dry run
|
|
59
|
+
s_output = `#{s_cmd}`
|
|
60
|
+
|
|
61
|
+
if !s_output.strip.empty?
|
|
62
|
+
put_line(s_repo, s_output)
|
|
63
|
+
s_cmd = "git commit -m \"#{s_cmd_opt}\" --quiet" # real run
|
|
64
|
+
s_output = `#{s_cmd}`
|
|
65
|
+
put_line(s_repo, s_output)
|
|
66
|
+
end
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
else
|
|
70
|
+
puts "to be implemented... #{s_cmd_name}"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
if b_block.nil?
|
|
74
|
+
b_block = Proc.new(){ |s_repo|
|
|
75
|
+
put_line(s_repo, `#{s_cmd}`)
|
|
76
|
+
}
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
run_cmd(@h_repos, s_cmd, &b_block)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# ----------------------------------------
|
|
85
|
+
def run_cmd(h_repos, s_cmd, &b_block)
|
|
86
|
+
h_repos.each { |s_repo, s_repo_path|
|
|
87
|
+
Dir.chdir(File.join('.', s_repo_path)){
|
|
88
|
+
b_block.call(s_repo)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# ----------------------------------------
|
|
94
|
+
def put_line(s_repo, s_output)
|
|
95
|
+
s_output.each_line { |s_sub_line|
|
|
96
|
+
puts "#{s_repo.ljust(@n_max_repo_len)} #{s_sub_line}"
|
|
97
|
+
}
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: gitdia
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
prerelease: 6
|
|
5
|
+
version: 0.0.1.pre
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Arete Inc
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-05-31 00:00:00.000000000Z
|
|
13
|
+
dependencies: []
|
|
14
|
+
description: A simple gem
|
|
15
|
+
email: dev@areteinc.com
|
|
16
|
+
executables:
|
|
17
|
+
- gitdia
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- lib/gitdia.rb
|
|
22
|
+
- bin/gitdia
|
|
23
|
+
homepage: https://github.com/areteinc/gitdia
|
|
24
|
+
licenses: []
|
|
25
|
+
post_install_message:
|
|
26
|
+
rdoc_options: []
|
|
27
|
+
require_paths:
|
|
28
|
+
- lib
|
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ! '>='
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
none: false
|
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ! '>'
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: 1.3.1
|
|
40
|
+
none: false
|
|
41
|
+
requirements: []
|
|
42
|
+
rubyforge_project:
|
|
43
|
+
rubygems_version: 1.8.15
|
|
44
|
+
signing_key:
|
|
45
|
+
specification_version: 3
|
|
46
|
+
summary: GitDia!
|
|
47
|
+
test_files: []
|
|
48
|
+
...
|