Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-03-22 01:25:54 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-03-22 01:25:54 +0300
commitfad1c2e7c3fc6fb7ab39bd17db636f49c54bbe53 (patch)
treeb1c09442ab8486fa5fbb0804a5e01b30546e88ef /app
parent63da396f59be2ef8af091f10979934f085139771 (diff)
parent5b432e76710eb70cc41c59af1ea9a294202a49fc (diff)
Merge branch 'topic/push_tag_events_for_ci' of https://github.com/ayufan/gitlabhq into ayufan-topic/push_tag_events_for_ci
Diffstat (limited to 'app')
-rw-r--r--app/services/create_tag_service.rb3
-rw-r--r--app/services/git_push_service.rb60
-rw-r--r--app/services/git_tag_push_service.rb18
3 files changed, 47 insertions, 34 deletions
diff --git a/app/services/create_tag_service.rb b/app/services/create_tag_service.rb
index af4b537cb93..4115d689925 100644
--- a/app/services/create_tag_service.rb
+++ b/app/services/create_tag_service.rb
@@ -40,7 +40,8 @@ class CreateTagService < BaseService
end
def create_push_data(project, user, tag)
+ commits = [project.repository.commit(tag.target)].compact
Gitlab::PushDataBuilder.
- build(project, user, Gitlab::Git::BLANK_SHA, tag.target, "#{Gitlab::Git::TAG_REF_PREFIX}#{tag.name}", [])
+ build(project, user, Gitlab::Git::BLANK_SHA, tag.target, "#{Gitlab::Git::TAG_REF_PREFIX}#{tag.name}", commits, tag.message)
end
end
diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb
index a0da07f5c90..1f0b29dff5e 100644
--- a/app/services/git_push_service.rb
+++ b/app/services/git_push_service.rb
@@ -23,42 +23,40 @@ class GitPushService
project.repository.expire_cache
project.update_repository_size
- if push_to_branch?(ref)
- if push_remove_branch?(ref, newrev)
- @push_commits = []
- elsif push_to_new_branch?(ref, oldrev)
- # Re-find the pushed commits.
- if is_default_branch?(ref)
- # Initial push to the default branch. Take the full history of that branch as "newly pushed".
- @push_commits = project.repository.commits(newrev)
-
- # Set protection on the default branch if configured
- if (current_application_settings.default_branch_protection != PROTECTION_NONE)
- developers_can_push = current_application_settings.default_branch_protection == PROTECTION_DEV_CAN_PUSH ? true : false
- project.protected_branches.create({ name: project.default_branch, developers_can_push: developers_can_push })
- end
- else
- # Use the pushed commits that aren't reachable by the default branch
- # as a heuristic. This may include more commits than are actually pushed, but
- # that shouldn't matter because we check for existing cross-references later.
- @push_commits = project.repository.commits_between(project.default_branch, newrev)
-
- # don't process commits for the initial push to the default branch
- process_commit_messages(ref)
+ if push_remove_branch?(ref, newrev)
+ @push_commits = []
+ elsif push_to_new_branch?(ref, oldrev)
+ # Re-find the pushed commits.
+ if is_default_branch?(ref)
+ # Initial push to the default branch. Take the full history of that branch as "newly pushed".
+ @push_commits = project.repository.commits(newrev)
+
+ # Set protection on the default branch if configured
+ if (current_application_settings.default_branch_protection != PROTECTION_NONE)
+ developers_can_push = current_application_settings.default_branch_protection == PROTECTION_DEV_CAN_PUSH ? true : false
+ project.protected_branches.create({ name: project.default_branch, developers_can_push: developers_can_push })
end
- elsif push_to_existing_branch?(ref, oldrev)
- # Collect data for this git push
- @push_commits = project.repository.commits_between(oldrev, newrev)
- project.update_merge_requests(oldrev, newrev, ref, @user)
+ else
+ # Use the pushed commits that aren't reachable by the default branch
+ # as a heuristic. This may include more commits than are actually pushed, but
+ # that shouldn't matter because we check for existing cross-references later.
+ @push_commits = project.repository.commits_between(project.default_branch, newrev)
+
+ # don't process commits for the initial push to the default branch
process_commit_messages(ref)
end
+ elsif push_to_existing_branch?(ref, oldrev)
+ # Collect data for this git push
+ @push_commits = project.repository.commits_between(oldrev, newrev)
+ project.update_merge_requests(oldrev, newrev, ref, @user)
+ process_commit_messages(ref)
+ end
- @push_data = build_push_data(oldrev, newrev, ref)
+ @push_data = build_push_data(oldrev, newrev, ref)
- EventCreateService.new.push(project, user, @push_data)
- project.execute_hooks(@push_data.dup, :push_hooks)
- project.execute_services(@push_data.dup, :push_hooks)
- end
+ EventCreateService.new.push(project, user, @push_data)
+ project.execute_hooks(@push_data.dup, :push_hooks)
+ project.execute_services(@push_data.dup, :push_hooks)
end
protected
diff --git a/app/services/git_tag_push_service.rb b/app/services/git_tag_push_service.rb
index 0d8e6e85e47..bf203bbd692 100644
--- a/app/services/git_tag_push_service.rb
+++ b/app/services/git_tag_push_service.rb
@@ -3,7 +3,7 @@ class GitTagPushService
def execute(project, user, oldrev, newrev, ref)
@project, @user = project, user
-
+
@push_data = build_push_data(oldrev, newrev, ref)
EventCreateService.new.push(project, user, @push_data)
@@ -18,6 +18,20 @@ class GitTagPushService
private
def build_push_data(oldrev, newrev, ref)
- Gitlab::PushDataBuilder.build(project, user, oldrev, newrev, ref, [])
+ commits = []
+ message = nil
+
+ if !Gitlab::Git.blank_ref?(newrev)
+ tag_name = Gitlab::Git.ref_name(ref)
+ tag = project.repository.find_tag(tag_name)
+ if tag && tag.target == newrev
+ commit = project.repository.commit(tag.target)
+ commits = [commit].compact
+ message = tag.message
+ end
+ end
+
+ Gitlab::PushDataBuilder.
+ build(project, user, oldrev, newrev, ref, commits, message)
end
end