Skip to content

Commit

Permalink
added
Browse files Browse the repository at this point in the history
  • Loading branch information
vidhvath28 committed Aug 30, 2024
1 parent 78b3402 commit 3deb154
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
12 changes: 12 additions & 0 deletions shards.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
spectator = {
url = "https://gitlab.com/arctic-fox/spectator.git";
rev = "v0.10.6";
sha256 = "0w6mv1q44is2m19pyspkyiwm84h55nchsm4pp82gdbb0j9ylhckx";
};
version_from_shard = {
url = "https://github.com/hugopl/version_from_shard.git";
rev = "v1.2.5";
sha256 = "0xizj0q4rd541rwjbx04cjifc2gfx4l5v6q2y7gmd0ndjmkgb8ik";
};
}
25 changes: 12 additions & 13 deletions src/worker.cr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module Crystal2Nix
end

def run
errors = [] of String
temp_file_path = "#{SHARDS_NIX}.tmp"

File.open temp_file_path, "w+" do |file|
Expand All @@ -21,8 +20,7 @@ module Crystal2Nix
begin
repo = Repo.new value
rescue ex : Exception
log_message = "Error processing repository '#{key}': #{ex.message}. Please check the repository details and try again."

log_message "Error processing repository '#{key}': #{ex.message}. Please check the repository details and try again."
next
end

Expand All @@ -41,11 +39,10 @@ module Crystal2Nix
sha256 = GitPrefetchJSON.from_json(json_output).sha256
end
rescue ex : Exception
log_message = "Error running nix-prefetch-git for '#{key}': #{ex.message}.
log_message "Error running nix-prefetch-git for '#{key}': #{ex.message}.
Try running the command manually to troubleshoot:
nix-prefetch-git #{args.join " "}
Ensure that the git repository is accessible and try again."

next
end

Expand All @@ -61,19 +58,18 @@ module Crystal2Nix
sha256 = output.strip.split("\n").first
end
rescue ex : Exception
log_message = "Error running nix-prefetch-hg for '#{key}': #{ex.message}.
log_message "Error running nix-prefetch-hg for '#{key}': #{ex.message}.
Try running the command manually to troubleshoot:
nix-prefetch-hg #{args.join " "}
Ensure that the Mercurial repository is accessible and try again."

next
end

else
log_message = "Unsupported repository type for '#{key}': #{repo.type}. Currently supported types are: git, hg. Please update your configuration or contact support for further assistance."

log_message "Unsupported repository type for '#{key}': #{repo.type}. Currently supported types are: git, hg. Please update your configuration or contact support for further assistance."
break
end

file.puts %( #{key} = {)
file.puts %( url = "#{repo.url}";)
file.puts %( rev = "#{repo.rev}";)
Expand All @@ -82,15 +78,18 @@ module Crystal2Nix
end
file.puts %(})
end
if errors.empty?

# Check the instance variable @errors instead of the local errors array
if @errors.any?
File.delete(temp_file_path)
STDERR.puts "\nSummary of errors encountered:"
errors.each { |error| STDERR.puts " - #{error}" }
@errors.each { |error| STDERR.puts " - #{error}" }
STDERR.puts "\nProcess not completed due to the above errors. Please review and resolve them before re-running."
exit 1
end
File.rename(temp_file_path, SHARDS_NIX)
puts "Processing completed successfully with no errors."

File.rename(temp_file_path, SHARDS_NIX)
puts "Processing completed successfully with no errors."
end
end
end

0 comments on commit 3deb154

Please sign in to comment.