mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-23 21:17:58 +00:00
dc10d1520d
* Move CI scripts to new location * Update references * Update CODEOWNERS file * Update docker/polkadot-collator_builder.Containerfile Co-authored-by: Alexander Samusev <41779041+alvicsam@users.noreply.github.com> Co-authored-by: Alexander Samusev <41779041+alvicsam@users.noreply.github.com>
33 lines
807 B
Ruby
33 lines
807 B
Ruby
# frozen_string_literal: true
|
|
|
|
# A Class to find Substrate references
|
|
class SubRef
|
|
require 'octokit'
|
|
require 'toml'
|
|
|
|
attr_reader :client, :repository
|
|
|
|
def initialize(github_repo)
|
|
@client = Octokit::Client.new(
|
|
access_token: ENV['GITHUB_TOKEN']
|
|
)
|
|
@repository = @client.repository(github_repo)
|
|
end
|
|
|
|
# This function checks the Cargo.lock of a given
|
|
# Rust project, for a given package, and fetches
|
|
# the dependency git ref.
|
|
def get_dependency_reference(ref, package)
|
|
cargo = TOML::Parser.new(
|
|
Base64.decode64(
|
|
@client.contents(
|
|
@repository.full_name,
|
|
path: 'Cargo.lock',
|
|
query: { ref: ref.to_s }
|
|
).content
|
|
)
|
|
).parsed
|
|
cargo['package'].find { |p| p['name'] == package }['source'].split('#').last
|
|
end
|
|
end
|