class BitBucket::Repos
Constants
- DEFAULT_REPO_OPTIONS
- VALID_REPO_OPTIONS
Public Class Methods
Creates new Repositories API
BitBucket::API::new
# File lib/bitbucket_rest_api/repos.rb, line 46 def initialize(options = { }) super(options) end
Public Instance Methods
List branches
Examples¶ ↑
bitbucket = BitBucket.new bibucket.repos.branches 'user-name', 'repo-name' repos = BitBucket::Repos.new repos.branches 'user-name', 'repo-name'
# File lib/bitbucket_rest_api/repos.rb, line 114 def branches(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("/1.0/repositories/#{user}/#{repo.downcase}/branches/", params) return response unless block_given? response.each { |el| yield el } end
Access to Repos::Commits
API
# File lib/bitbucket_rest_api/repos.rb, line 51 def changesets @changesets ||= ApiFactory.new 'Repos::Changesets' end
# File lib/bitbucket_rest_api/repos.rb, line 80 def commit @commit ||=ApiFactory.new 'Repos::Commit' end
# File lib/bitbucket_rest_api/repos.rb, line 77 def commits @commits ||=ApiFactory.new 'Repos::Commits' end
# File lib/bitbucket_rest_api/repos.rb, line 96 def components @components ||= ApiFactory.new 'Repos::Components' end
FIXME: 'POST a new repository' is a deprecated feature of the API
Create a new repository for the authenticated user.
Parameters¶ ↑
<tt>:name</tt> - Required string <tt>:description</tt> - Optional string <tt>:website</tt> - Optional string <tt>:is_private</tt> - Optional boolean - <tt>true</tt> to create a private repository, <tt>false</tt> to create a public one. <tt>:has_issues</tt> - Optional boolean - <tt>true</tt> to enable issues for this repository, <tt>false</tt> to disable them <tt>:has_wiki</tt> - Optional boolean - <tt>true</tt> to enable the wiki for this repository, <tt>false</tt> to disable it. Default is <tt>true</tt> <tt>:owner</tt> Optional string - The team in which this repository will be created
Examples¶ ↑
bitbucket = BitBucket.new bitbucket.repos.create "name" => 'repo-name' "description": "This is your first repo", "website": "https://bitbucket.com", "is_private": false, "has_issues": true, "has_wiki": true
Create a new repository in this team. The authenticated user must be a member of this team
Examples:
bitbucket = BitBucket.new :oauth_token => '...', :oauth_secret => '...' bitbucket.repos.create :name => 'repo-name', :owner => 'team-name'
# File lib/bitbucket_rest_api/repos.rb, line 154 def create(*args) params = args.extract_options! normalize! params filter! VALID_REPO_OPTIONS + %w[ org ], params assert_required_keys(%w[ name ], params) # Requires authenticated user post_request("/1.0/repositories/", DEFAULT_REPO_OPTIONS.merge(params)) end
# File lib/bitbucket_rest_api/repos.rb, line 92 def default_reviewers @default_reviewers ||= ApiFactory.new 'Repos::DefaultReviewers' end
FIXME: 'DELETE an existing repository' is a deprecated feature of the API
Delete a repository
Examples¶ ↑
@bitbucket = BitBucket.new @bitbucket.repos.delete 'user-name', 'repo-name'
# File lib/bitbucket_rest_api/repos.rb, line 217 def delete(user_name, repo_name) _update_user_repo_params(user_name, repo_name) _validate_user_repo_params(user, repo) unless user? && repo? delete_request("/1.0/repositories/#{user}/#{repo.downcase}") end
# File lib/bitbucket_rest_api/repos.rb, line 83 def download @download ||=ApiFactory.new "Repos::Download" end
Edit a repository
Parameters¶ ↑
-
:name
Required string -
:description
Optional string -
:website
Optional string -
:private
- Optional boolean -false
to create public reps,false
to create a private one -
:has_issues
Optional boolean -true
to enable issues for this repository,false
to disable them -
:has_wiki
Optional boolean -true
to enable the wiki for this repository,false
to disable it. Default istrue
-
:has_downloads
Optional boolean -true
to enable downloads for this repository
Examples¶ ↑
bitbucket = BitBucket.new bitbucket.repos.edit 'user-name', 'repo-name', :name => 'hello-world', :description => 'This is your first repo', :website => "https://bitbucket.com", :public => true, :has_issues => true
# File lib/bitbucket_rest_api/repos.rb, line 184 def edit(user_name, repo_name, params={ }) _update_user_repo_params(user_name, repo_name) _validate_user_repo_params(user, repo) unless user? && repo? normalize! params filter! VALID_REPO_OPTIONS, params put_request("/1.0/repositories/#{user}/#{repo.downcase}/", DEFAULT_REPO_OPTIONS.merge(params)) end
Access to Repos::Watchin API
# File lib/bitbucket_rest_api/repos.rb, line 61 def following @following ||= ApiFactory.new 'Repos::Following' end
# File lib/bitbucket_rest_api/repos.rb, line 74 def forks @forks ||= ApiFactory.new 'Repos::Forks' end
Get a repository
Examples¶ ↑
bitbucket = BitBucket.new bitbucket.repos.get 'user-name', 'repo-name'
# File lib/bitbucket_rest_api/repos.rb, line 200 def get(user_name, repo_name, params={ }) _update_user_repo_params(user_name, repo_name) _validate_user_repo_params(user, repo) unless user? && repo? normalize! params get_request("/1.0/repositories/#{user}/#{repo.downcase}", params) end
Access to Repos::Keys
API
# File lib/bitbucket_rest_api/repos.rb, line 56 def keys @keys ||= ApiFactory.new 'Repos::Keys' end
List repositories for the authenticated user
Examples¶ ↑
bitbucket = BitBucket.new :oauth_token => '...', :oauth_secret => '...' bitbucket.repos.list bitbucket.repos.list { |repo| ... }
List public repositories for the specified user.
Examples¶ ↑
bitbucket = BitBucket.new bitbucket.repos.list :user => 'user-name', :role => 'owner' bitbucket.repos.list :user => 'user-name', { |repo| ... }
# File lib/bitbucket_rest_api/repos.rb, line 237 def list(*args) params = args.extract_options! normalize! params _merge_user_into_params!(params) unless params.has_key?('user') params.merge!('pagelen' => 100) unless params.has_key?('pagelen') filter! %w[ user role pagelen ], params response = get_request("/2.0/repositories", params) response = response[:values] return response unless block_given? response.each { |el| yield el } end
Access to Repos::PullRequests API
# File lib/bitbucket_rest_api/repos.rb, line 88 def pull_request @pull_request ||= ApiFactory.new 'Repos::PullRequest' end
Access to Repos::Services
API
# File lib/bitbucket_rest_api/repos.rb, line 71 def services @services ||= ApiFactory.new 'Repos::Services' end
Access to Repos::Commits
API
# File lib/bitbucket_rest_api/repos.rb, line 66 def sources @sources ||= ApiFactory.new 'Repos::Sources' end
# File lib/bitbucket_rest_api/repos.rb, line 100 def webhooks @webhooks ||= ApiFactory.new 'Repos::Webhooks' end