summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-02 10:45:13 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-02 10:45:13 +0200
commit3d416f1682c5e6a6ac1ea7013f66bbd0d23b452c (patch)
tree42df25ecb88654ef08549608122d89ddd5f45f82
parent2c403dfd924e0b1f5bc8a7a70d0ae757b350b7ee (diff)
downloadgitlab-ce-3d416f1682c5e6a6ac1ea7013f66bbd0d23b452c.tar.gz
Create activity event and execute hooks on web editor commit
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--app/services/files/base_service.rb6
-rw-r--r--app/services/files/create_service.rb5
-rw-r--r--app/services/files/update_service.rb3
3 files changed, 11 insertions, 3 deletions
diff --git a/app/services/files/base_service.rb b/app/services/files/base_service.rb
index bd245100955..29013be0f97 100644
--- a/app/services/files/base_service.rb
+++ b/app/services/files/base_service.rb
@@ -13,5 +13,11 @@ module Files
def repository
project.repository
end
+
+ def after_commit(sha)
+ commit = repository.commit(sha)
+ full_ref = 'refs/heads/' + (params[:new_branch] || ref)
+ GitPushService.new.execute(project, current_user, commit.parent_id, sha, full_ref)
+ end
end
end
diff --git a/app/services/files/create_service.rb b/app/services/files/create_service.rb
index 3516cf30dbc..bafc3565da1 100644
--- a/app/services/files/create_service.rb
+++ b/app/services/files/create_service.rb
@@ -40,7 +40,7 @@ module Files
params[:content]
end
- created_successfully = repository.commit_file(
+ sha = repository.commit_file(
current_user,
file_path,
content,
@@ -49,7 +49,8 @@ module Files
)
- if created_successfully
+ if sha
+ after_commit(sha)
success
else
error("Your changes could not be committed, because the file has been changed")
diff --git a/app/services/files/update_service.rb b/app/services/files/update_service.rb
index 4d7ac3b7504..c972f8322bb 100644
--- a/app/services/files/update_service.rb
+++ b/app/services/files/update_service.rb
@@ -26,7 +26,7 @@ module Files
params[:content]
end
- repository.commit_file(
+ sha = repository.commit_file(
current_user,
path,
content,
@@ -34,6 +34,7 @@ module Files
params[:new_branch] || ref
)
+ after_commit(sha)
success
rescue Gitlab::Satellite::CheckoutFailed => ex
error("Your changes could not be committed because ref '#{ref}' could not be checked out", 400)