Created
March 15, 2015 16:46
-
-
Save KenshoFujisaki/760a9d62263c488319e3 to your computer and use it in GitHub Desktop.
GitLab向けリモートフックスクリプト:トピックブランチ以外のpush禁止
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/gitlab/embedded/bin/ruby | |
# Fix the PATH so that gitlab-shell can find git-upload-pack and friends. | |
ENV['PATH'] = '/opt/gitlab/bin:/opt/gitlab/embedded/bin:' + ENV['PATH'] | |
#!/usr/bin/env ruby | |
# This file was placed here by GitLab. It makes sure that your pushed commits | |
# will be processed properly. | |
# You can add your own hooks to this file, but be careful when updating gitlab-shell! | |
refname = ARGV[0] | |
key_id = ENV['GL_ID'] | |
repo_path = Dir.pwd | |
# トピックブランチ(feature/bugfix/refactoring)以外のpushを禁じる | |
regex_matches = /(?<topic_type>feature|bugfix|refactoring)(?<topic_type_detail>|_.*)\/(?<ticket_number>\d+)/.match(refname) | |
if regex_matches.nil? | |
p "----------------------------------------------------------------------------------" | |
p "This push is not allowed. The branch name is invalid." | |
p "Following branch name is only allowed: /(feature|bugfix|refactoring)(|_.*)\/(\d+)/" | |
p "----------------------------------------------------------------------------------" | |
exit 1 | |
end | |
require_relative '../lib/gitlab_update' | |
GitlabUpdate.new(repo_path, key_id, refname).exec |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/var/opt/gitlab/git-data/repositories/[user_name]/[repository_name].git/hooks/update