module Gitlab::Client::RepositoryFile

Overview

Defines methods related to repository.

See https://docs.gitlab.com/ce/api/repository_files.html

Direct including types

Defined in:

gitlab/client/repository_file.cr

Instance Method Summary

Instance Method Detail

def create_file(project : String | Int32, path : String, branch : String, content : String, commit_message : String, options : Hash = {} of String => String) : JSON::Any #

Creates a new repository file.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • param [String] filepath The path and name of a file. Do not URL-encode
  • param [String] branch The branch to create the file in
  • param [String] content The raw file contents
  • param [String] commit_message The commit message
  • param [Hash] options A customizable set of options.
  • option form [String] :author_name Commit author's name
  • option form [String] :author_email Commit author's email
client.create_file("my-stuff/example-repo".gsub("/", "%2F"), "some/dir/file.txt", "master", "Hello World\ncreated by gitlab.cr", "Just did it", {} of String => String)

def file_contents(project_id : Int32, filepath : String, sha = "HEAD") : String #

Get the raw file contents for a file by commit SHA and path.

  • param [Int32] project The ID of a project.
  • param [String] filepath The path and name of a file.
  • param [String] sha The id of a commit sha.
  • return [String] The raw file contents
client.file_contents(1, "README.md")
client.file_contents(1, "src/gitlab.cr", "a5c805f456f46b44e270f342330b06e06c53cbcc")

def get_file(project_id : Int32, filepath : String, ref = "HEAD") #

Gets a repository file.

  • param [Int32] project The ID or name of a project.
  • param [String] file_path The full path of the file.
  • param [String] ref The name of branch, tag or commit.
  • return [JSON::Any]
client.get_file(42, "README.md")
client.get_file(42, "README.md", "develop")