Skip to content

Commit 1098f40

Browse files
committed
Improve code of HgResolver
1 parent a1d3338 commit 1098f40

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/resolvers/hg.cr

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ module Shards
202202

203203
protected def versions_from_tags
204204
capture("hg tags --template #{Process.quote("{tag}\n")}")
205-
.split('\n')
205+
.lines
206206
.sort!
207207
.compact_map { |tag| Version.new($1) if tag =~ VERSION_TAG }
208208
end
@@ -267,7 +267,6 @@ module Shards
267267
return HgTagRef.new value
268268
when "commit"
269269
return HgCommitRef.new value
270-
else
271270
end
272271
end
273272

@@ -329,7 +328,7 @@ module Shards
329328
source = hg_url
330329
# Remove a "file://" from the beginning, otherwise the path might be invalid
331330
# on Windows.
332-
source = source[7..] if source.starts_with?("file://")
331+
source = source.lchop("file://")
333332

334333
hg_retry(err: "Failed to clone #{source}") do
335334
# We checkout the working directory so that "." is meaningful.
@@ -349,8 +348,7 @@ module Shards
349348
private def hg_retry(err = "Failed to update repository")
350349
retries = 0
351350
loop do
352-
yield
353-
break
351+
return yield
354352
rescue ex : Error
355353
retries += 1
356354
next if retries < 3

0 commit comments

Comments
 (0)