gitdia 0.0.1.pre → 0.0.2.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/lib/gitdia.rb +19 -12
- metadata +1 -1
data/lib/gitdia.rb
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
# available commands are:
|
|
4
|
-
# gita status
|
|
5
|
-
# gita add all
|
|
6
|
-
# gita commit "msg..."
|
|
7
|
-
|
|
8
2
|
require 'yaml'
|
|
9
3
|
|
|
4
|
+
# ----------------------------------------
|
|
10
5
|
class GitDia
|
|
11
6
|
|
|
12
7
|
attr :h_repos
|
|
13
8
|
attr :n_max_repo_len # formatting
|
|
14
9
|
|
|
10
|
+
# ----------------------------------------
|
|
11
|
+
def clone_repos()
|
|
12
|
+
@h_repos.each { |s_repo, h_repo|
|
|
13
|
+
s_cmd = "git clone git@github.com:#{h_repo["owner"]}/#{s_repo}.git #{h_repo["dir"]}"
|
|
14
|
+
puts `#{s_cmd}`
|
|
15
|
+
}
|
|
16
|
+
end
|
|
17
|
+
|
|
15
18
|
# ----------------------------------------
|
|
16
19
|
def load_config()
|
|
17
20
|
s_config_file = File.join(Dir.home(), '.gitdia')
|
|
@@ -23,15 +26,13 @@ class GitDia
|
|
|
23
26
|
|
|
24
27
|
@n_max_repo_len = 0
|
|
25
28
|
@h_repos = h_config["repos"]
|
|
26
|
-
@h_repos.each { |s_repo,
|
|
27
|
-
@n_max_repo_len = [
|
|
29
|
+
@h_repos.each { |s_repo, h_repo|
|
|
30
|
+
@n_max_repo_len = [h_repo["dir"].length, @n_max_repo_len].max
|
|
28
31
|
}
|
|
29
32
|
end
|
|
30
33
|
|
|
31
34
|
# ----------------------------------------
|
|
32
35
|
def git()
|
|
33
|
-
# looking for .gitdia file under user home
|
|
34
|
-
# create one if not exist
|
|
35
36
|
|
|
36
37
|
load_config()
|
|
37
38
|
|
|
@@ -43,6 +44,9 @@ class GitDia
|
|
|
43
44
|
b_block = nil
|
|
44
45
|
|
|
45
46
|
case s_cmd_name
|
|
47
|
+
when 'clone'
|
|
48
|
+
clone_repos()
|
|
49
|
+
return
|
|
46
50
|
when 'status'
|
|
47
51
|
s_cmd = 'git status --porcelain'
|
|
48
52
|
when 'add'
|
|
@@ -52,6 +56,9 @@ class GitDia
|
|
|
52
56
|
else
|
|
53
57
|
puts "to be implemented: #{s_cmd_opt}"
|
|
54
58
|
end
|
|
59
|
+
when 'diff'
|
|
60
|
+
s_file_name = s_cmd_opt
|
|
61
|
+
s_cmd = "git difftool #{s_file_name}"
|
|
55
62
|
when 'commit'
|
|
56
63
|
|
|
57
64
|
b_block = Proc.new(){ |s_repo|
|
|
@@ -83,8 +90,8 @@ class GitDia
|
|
|
83
90
|
|
|
84
91
|
# ----------------------------------------
|
|
85
92
|
def run_cmd(h_repos, s_cmd, &b_block)
|
|
86
|
-
h_repos.each { |s_repo,
|
|
87
|
-
Dir.chdir(File.join('.',
|
|
93
|
+
h_repos.each { |s_repo, h_repo|
|
|
94
|
+
Dir.chdir(File.join('.', h_repo["dir"])){
|
|
88
95
|
b_block.call(s_repo)
|
|
89
96
|
}
|
|
90
97
|
}
|