Sha256: 510c6477488a9aef150c08b51ad77cbc83d7ec47279404555cb69bdf64c179cf

Contents?: true

Size: 1.85 KB

Versions: 6

Compression:

Stored size: 1.85 KB

Contents

# encoding: utf-8

module BitBucket
  class Repos::Forks < API

    REQUIRED_KEY_PARAM_NAMES = %w[ name ].freeze
    DEFAULT_REPO_OPTIONS = {
        "website"         => "",
        "is_private"      => false,
        "has_issues"      => false,
        "has_wiki"        => false,
        "scm"             => "git",
        "no_public_forks" => false
    }.freeze

    VALID_REPO_OPTIONS = %w[
      owner
      name
      description
      website
      is_private
      has_issues
      has_wiki
      no_public_forks
      language
      scm
    ].freeze

    # List forks of a repo
    #
    # = Examples
    #  bitbucket = BitBucket.new
    #  bitbucket.repos.forks.list 'user-name', 'repo-name'
    #  bitbucket.repos.forks.list 'user-name', 'repo-name' { |fork| ... }
    #
    def list(user_name, repo_name, params={})
      _update_user_repo_params(user_name, repo_name)
      _validate_user_repo_params(user, repo) unless user? && repo?
      normalize! params

      response = get_request("/2.0/repositories/#{user}/#{repo.downcase}/forks/", params)
      return response unless block_given?
      response.each { |el| yield el }
    end
    alias :all :list

    # Create a fork
    #
    # = Inputs
    # * <tt>:type</tt> - One of the supported services. The type is a case-insensitive value.
    #
    # = Examples
    #  bitbucket = BitBucket.new
    #  bitbucket.repos.forks.create 'user-name', 'repo-name',
    #    "name"           => "Basecamp",
    #
    def create(user_name, repo_name, params={})
      _update_user_repo_params(user_name, repo_name)
      _validate_user_repo_params(user, repo) unless user? && repo?
      normalize! params
      assert_required_keys(REQUIRED_KEY_PARAM_NAMES, params)
      filter! VALID_REPO_OPTIONS, params

      post_request("/1.0/repositories/#{user}/#{repo.downcase}/fork", params)
    end


  end # Repos::Keys
end # BitBucket

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
zz_bitbucket_rest_api-0.1.11 lib/bitbucket_rest_api/repos/forks.rb
zz_bitbucket_rest_api-0.1.10 lib/bitbucket_rest_api/repos/forks.rb
zz_bitbucket_rest_api-0.1.9 lib/bitbucket_rest_api/repos/forks.rb
zz_bitbucket_rest_api-0.1.8 lib/bitbucket_rest_api/repos/forks.rb
bitbucket_rest_api2-0.9.5 lib/bitbucket_rest_api/repos/forks.rb
bitbucket_rest_api-0.1.7 lib/bitbucket_rest_api/repos/forks.rb