Gitlab::Client::Repository
Defines methods related to repository.
Instance methods
Get the raw file contents for a blob by blob SHA.
- param [Int32] project The ID of a project.
- param [String] sha The id of a commit sha.
- return [String] The raw file contents
client.blow_contents(1, "74bbc1b7")
client.blow_contents(1, "a5c805f456f46b44e270f342330b06e06c53cbcc")
Compare branches, tags or commits.
- param [Int32] project The ID of a project.
- param [String] from the commit SHA or branch name.
- param [String] to the commit SHA or branch name.
- return [JSON::Any] List a compare between from and to.
client.compare(1, "master", "develop")
client.compare(1, "a5c805f4", "v1.0.0")
Get repository contributors list
- param [Int32] project The ID of a project.
- params [Hash] options A customizable set of options.
- option params [Int32] :page The page number.
- option params [Int32] :per_page The number of results per page.
- return [JSON::Any] List of projects of the authorized user.
client.contributors(1)
client.contributors(1, {"per_page" => "10"})
Get an archive of the repository.
- param [Int32] project The ID of a project.
- param [String] sha The commit SHA to download defaults to the tip of the default branch.
- return [Gitlab::FileResponse, JSON::Any] The archive file.
file = client.repo_archive(1)
file = client.repo_archive(1, "a5c805f456f46b44e270f342330b06e06c53cbcc")
if file.is_a?(Gitlab::FileResponse)
puts file.filename # => "test-HEAD-a5c805f456f46b44e270f342330b06e06c53cbcc.tar.gz"
File.open(file.filename, "w") do |f|
while byte = r.data.read_byte
f.write_byte byte
end
end
end
Get a list of repository files and directories in a project.
- param [Int32] project The ID of a project.
- param [Hash] params A customizable set of params.
- option params [String] :path The path inside repository. Used to get contend of subdirectories.
- option params [String] :ref The name of a repository branch or tag or if not given the default branch
- return [JSON::Any]
client.tree(42)
client.tree(42, {"path" => "shard.yml"})