Skip to content

Commit

Permalink
Remove form web_hook controller and add into gitlab controller. havin…
Browse files Browse the repository at this point in the history
…g to pull parent function down.

added to spec file.
  • Loading branch information
David Wylie committed Jan 24, 2018
1 parent 37984d4 commit febbf35
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
Expand Up @@ -21,6 +21,39 @@ class GitLabController < WebHookController
before_action :allow_only_push_event
before_action :verify_payload

def notify
possible_urls = %W(
https://#{repo_host_name}/#{repo_full_name}
https://#{repo_host_name}/#{repo_full_name}/
https://#{repo_host_name}/#{repo_full_name}.git
https://#{repo_host_name}/#{repo_full_name}.git/
http://#{repo_host_name}/#{repo_full_name}
http://#{repo_host_name}/#{repo_full_name}/
http://#{repo_host_name}/#{repo_full_name}.git
http://#{repo_host_name}/#{repo_full_name}.git/
git://#{repo_host_name}/#{repo_full_name}
git://#{repo_host_name}/#{repo_full_name}/
git://#{repo_host_name}/#{repo_full_name}.git
git://#{repo_host_name}/#{repo_full_name}.git/
git@#{repo_host_name}:#{repo_full_name}
git@#{repo_host_name}:#{repo_full_name}/
git@#{repo_host_name}:#{repo_full_name}.git
git@#{repo_host_name}:#{repo_full_name}.git/
gitlab@#{repo_host_name}:#{repo_full_name}
gitlab@#{repo_host_name}:#{repo_full_name}/
gitlab@#{repo_host_name}:#{repo_full_name}.git
gitlab@#{repo_host_name}:#{repo_full_name}.git/
)

Rails.logger.info("[WebHook] Noticed a git push to #{repo_host_name}/#{repo_full_name} on branch #{repo_branch}")

if material_update_service.updateGitMaterial(repo_branch, possible_urls)
render text: 'OK!', content_type: 'text/plain', status: :accepted, layout: nil
else
render text: 'No matching materials!', content_type: 'text/plain', status: :accepted, layout: nil
end
end

protected

def repo_branch
Expand Down
Expand Up @@ -35,10 +35,6 @@ def notify
git@#{repo_host_name}:#{repo_full_name}/
git@#{repo_host_name}:#{repo_full_name}.git
git@#{repo_host_name}:#{repo_full_name}.git/
gitlab@#{repo_host_name}:#{repo_full_name}
gitlab@#{repo_host_name}:#{repo_full_name}/
gitlab@#{repo_host_name}:#{repo_full_name}.git
gitlab@#{repo_host_name}:#{repo_full_name}.git/
)

Rails.logger.info("[WebHook] Noticed a git push to #{repo_host_name}/#{repo_full_name} on branch #{repo_branch}")
Expand Down
Expand Up @@ -73,7 +73,11 @@
git@gitlab.example.com:org/repo
git@gitlab.example.com:org/repo/
git@gitlab.example.com:org/repo.git
git@gitlab.example.com:org/repo.git/)
git@gitlab.example.com:org/repo.git/
gitlab@gitlab.example.com:org/repo
gitlab@gitlab.example.com:org/repo/
gitlab@gitlab.example.com:org/repo.git
gitlab@gitlab.example.com:org/repo.git/)

expect(@material_update_service)
.to receive(:updateGitMaterial)
Expand Down

0 comments on commit febbf35

Please sign in to comment.