Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/bitbucket_rest_api/repos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,24 @@ def branches(user_name, repo_name, params={})

alias :list_branches :branches

# Get main branch
#
# = Examples
#
# bitbucket = BitBucket.new
# bibucket.repos.main_branch 'user-name', 'repo-name'
#
# repos = BitBucket::Repos.new
# repos.main_branch 'user-name', 'repo-name'
#
def main_branch(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}/main-branch", params)
end

# FIXME: 'POST a new repository' is a deprecated feature of the API
# Create a new repository for the authenticated user.
#
Expand Down
15 changes: 15 additions & 0 deletions spec/bitbucket_rest_api/repos_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@
end
end

describe '.main_branch' do
before do
expect(repo).to receive(:request).with(
:get,
'/1.0/repositories/mock_username/mock_repo/main-branch',
{},
{}
)
end

it 'should send a GET request for the main branch' do
repo.main_branch('mock_username', 'mock_repo')
end
end

describe '.edit' do
before do
expect(repo).to receive(:request).with(
Expand Down