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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: acf08e82dbb468bf6ec004732671b57693535498
4
- data.tar.gz: 4bf075447945b0262854dc48b7a5880b9f63af4b
3
+ metadata.gz: 0eca1985ed6f721ba7fadd3aeadeb1dc4ca91b8c
4
+ data.tar.gz: 80aff1f5707dc05e6ca2d7b919a34a9b1ad08479
5
5
  SHA512:
6
- metadata.gz: 6c760656a84bc881b81fec72de9358c1b66474acf01417c23f4ffaf277b03be6aef30bf6533fa37efd9a863832daef231af22efdd3aa174abe7a33d851a6cc82
7
- data.tar.gz: '059c3acf0be1788cb8dc24ab4cc0abff364df1b8589e1e3c9439cf98c124e507b1b5ab040dbd7b718ac5b118535923d01edca99600bd2fee79fcc98d2ff459f3'
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. If the remote is different from
27
- what you have configured, it will show a warning.
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
 
@@ -55,19 +55,42 @@ module ElectricMonk
55
55
 
56
56
  def ensure_existence
57
57
  if exists?
58
- unless remote_correct?
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
- clone_project
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
@@ -1,3 +1,3 @@
1
1
  module ElectricMonk
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  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.1.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-10-31 00:00:00.000000000 Z
11
+ date: 2017-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toml-rb