travis-api/lib/travis/services/find_branch.rb
Aakriti Gupta 65f1a29d86 Move travis-core files from /vendor to /lib.
- Re-factor
- Remove code for notifications
- Remove addons
- Remove travis-core gem.
- Ignore logs directory only
- Move core tests to spec/lib
2016-07-20 11:22:25 +02:00

37 lines
654 B
Ruby

require 'core_ext/active_record/none_scope'
require 'travis/services/base'
module Travis
module Services
class FindBranch < Base
register :find_branch
def run
result
end
def updated_at
result.updated_at if result
end
private
def result
@result ||= params[:id] ? by_id : by_params
end
def by_id
scope(:build).find(params[:id])
end
def by_params
repo.last_build_on params[:branch] if repo and params[:branch]
end
def repo
@repo ||= run_service(:find_repo, params)
end
end
end
end