electric_monk 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/lib/electric_monk.rb +48 -5
- data/lib/electric_monk/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0eca1985ed6f721ba7fadd3aeadeb1dc4ca91b8c
|
4
|
+
data.tar.gz: 80aff1f5707dc05e6ca2d7b919a34a9b1ad08479
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f5a7204eecb4c4cbed24ce4266df0312c6f061aac1d38d680b91f4b7dee510a55340558e42394441cd0599bbcf761eb434199f381912b0b84c76c1a3192741b
|
7
|
+
data.tar.gz: 35d8c63a5a670b6ce6a089c7cdae131fb679ecd9bb297b1b3d97a80863794343dfc4c6caec37a33f35edbd49d3fc1bf206497816c328497ad642ad2098e44d32
|
data/README.md
CHANGED
@@ -23,8 +23,12 @@ origin = "git@github.com:moonglum/electric_monk.git"
|
|
23
23
|
```
|
24
24
|
|
25
25
|
Then run `electric_monk` to make sure, all projects have been cloned to your root directory. If
|
26
|
-
one is missing, `electric_monk` will clone the repository for you.
|
27
|
-
|
26
|
+
one is missing, `electric_monk` will clone the repository for you. For every existing repository it
|
27
|
+
will show a warning if:
|
28
|
+
|
29
|
+
* The remote is different from what you have configured
|
30
|
+
* There are uncommitted changes (aka. dirty files)
|
31
|
+
* There are unpushed branches
|
28
32
|
|
29
33
|
## Development
|
30
34
|
|
data/lib/electric_monk.rb
CHANGED
@@ -55,19 +55,42 @@ module ElectricMonk
|
|
55
55
|
|
56
56
|
def ensure_existence
|
57
57
|
if exists?
|
58
|
-
|
58
|
+
if remote_correct?
|
59
|
+
if dirty_files?
|
60
|
+
reporter.warn("#{name}: #{dirty_files} dirty files")
|
61
|
+
elsif unpushed_commits?
|
62
|
+
reporter.warn("#{name}: #{unpushed_commits} unpushed commits")
|
63
|
+
else
|
64
|
+
reporter.info(name)
|
65
|
+
end
|
66
|
+
else
|
59
67
|
reporter.warn("#{name}: Wrong remote '#{current_remote}'")
|
60
|
-
return
|
61
68
|
end
|
62
69
|
else
|
63
|
-
|
70
|
+
reporter.wait("Cloning #{name}", name) do
|
71
|
+
clone_project
|
72
|
+
end
|
64
73
|
end
|
65
|
-
|
66
|
-
reporter.info(name)
|
67
74
|
end
|
68
75
|
|
69
76
|
private
|
70
77
|
|
78
|
+
def dirty_files?
|
79
|
+
dirty_files > 0
|
80
|
+
end
|
81
|
+
|
82
|
+
def dirty_files
|
83
|
+
execute("git status --short", chdir: path).lines.length
|
84
|
+
end
|
85
|
+
|
86
|
+
def unpushed_commits?
|
87
|
+
unpushed_commits > 0
|
88
|
+
end
|
89
|
+
|
90
|
+
def unpushed_commits
|
91
|
+
execute("git log --oneline --branches --not --remotes", chdir: path).lines.length
|
92
|
+
end
|
93
|
+
|
71
94
|
def current_remote
|
72
95
|
execute("git remote get-url origin", chdir: path)
|
73
96
|
end
|
@@ -103,5 +126,25 @@ module ElectricMonk
|
|
103
126
|
def warn(msg)
|
104
127
|
puts "✗ #{msg}"
|
105
128
|
end
|
129
|
+
|
130
|
+
def wait(waiting_msg, done_msg)
|
131
|
+
chars = %w[⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏].cycle
|
132
|
+
show_spinner = true
|
133
|
+
|
134
|
+
spinner = Thread.new do
|
135
|
+
while show_spinner do
|
136
|
+
print "#{chars.next} #{waiting_msg}"
|
137
|
+
sleep 0.1
|
138
|
+
print "\b" * (waiting_msg.length + 2)
|
139
|
+
end
|
140
|
+
padding = waiting_msg.length > done_msg.length ? " " * (waiting_msg.length - done_msg.length) : ""
|
141
|
+
info(done_msg + padding)
|
142
|
+
end
|
143
|
+
|
144
|
+
yield.tap {
|
145
|
+
show_spinner = false
|
146
|
+
spinner.join
|
147
|
+
}
|
148
|
+
end
|
106
149
|
end
|
107
150
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: electric_monk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Dohmen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: toml-rb
|