2013-11-05 05:06:52 -05:00
|
|
|
module Files
|
2014-01-16 12:03:42 -05:00
|
|
|
class BaseService < ::BaseService
|
2013-11-05 05:06:52 -05:00
|
|
|
attr_reader :ref, :path
|
|
|
|
|
|
|
|
def initialize(project, user, params, ref, path = nil)
|
|
|
|
@project, @current_user, @params = project, user, params.dup
|
|
|
|
@ref = ref
|
|
|
|
@path = path
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def repository
|
|
|
|
project.repository
|
|
|
|
end
|
2015-06-02 04:45:13 -04:00
|
|
|
|
|
|
|
def after_commit(sha)
|
|
|
|
commit = repository.commit(sha)
|
|
|
|
full_ref = 'refs/heads/' + (params[:new_branch] || ref)
|
2015-06-02 06:06:40 -04:00
|
|
|
old_sha = commit.parent_id || Gitlab::Git::BLANK_SHA
|
|
|
|
GitPushService.new.execute(project, current_user, old_sha, sha, full_ref)
|
2015-06-02 04:45:13 -04:00
|
|
|
end
|
2013-11-05 05:06:52 -05:00
|
|
|
end
|
|
|
|
end
|