In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
1. Interception mode
There are two ways to enforce code review:
Hosting the warehouse on phabricator, adding hook to the code hosting server through herald to implement because our code is hosted on gitlab, so we use the second way to code review
Add hook on 2.gitlab server side
There are two ways for gitlab to add hook: local addition, global addition to the current warehouse, and all warehouses.
2.1 Local configuration
Cd / srv/gitlab/data/git-data/repositories/root/pipeline-example-go.git # the gitlab serve side enters the specific repository path mkdir custom_hooks # creates a custom hook directory touch pre-receive # creates a pre-receive file chmod 755 pre-receive # modifies the file permission pre-receive hook, which is executed when someone uses git push to push code to the warehouse Its content is as follows: #! / usr/bin/env pythonimport sys,osimport fileinputimport reimport jsonimport requestsdef has_been_reviewed (start_commit, end_commit): cmd = 'git rev-list% s..% s'% (start_commit, end_commit) ) Flag = False commits = os.popen (cmd). Readlines () pattern = re.compile (r'Differential Revision: (. *)') for commit in commits: cmd = 'git rev-list-- format=' +'% s% b'+'--max-count=1% s'% commit res = os.popen (cmd). Readlines () [- 2] match_str = pattern.match (res) if not Match_str: print ("Please use 'arc diff' to commit") continue http_url = match_str.group (1) url = "https://xxx/api/differential.query?api.token=*****" info = json.loads (requests.get (url) .text) for i in info [' result']: if I ['uri'] ! = http_url: continue if i ['statusName'] =' Accepted': Flag = True else: print ("Current Status:% s Need Review and Accepted "% I ['statusName']) break if Flag: sys.exit (0) else: sys.exit (1) if _ _ name__ = =" _ _ main__ ": for line in fileinput.input (): args = line.split ('') start_commit = args [0] end_commit = args [1] if start_commit! = '000000000000000000000000000000000000 'and end_commit! =' 000000000000000000000000000000000000000000000000000000000000000000: has_been_reviewed (start_commit End_commit) Code interpretation: 1.git rev-list-- format=%s%b-- max-count=1 ${commit_id} # get the submission information of git commit Default is the information after git commit-m, but after using arc diff, the information of arc diff will overwrite the content 2.requests.get of the previous git commit ("https://***/api/differential.query?api.token=***") # obtains all the differential information through the api interface of ph, in which token can obtain 3.# information of differential through https://***/conduit/login/, then select uri as the currently submitted revision If the status Accepted, the code review passes, exits the program, and returns the status code 0, it means that the status code is not intercepted. If the status is not Accepted, the status code is not 0, which means the execution failed and the git push request is intercepted.
***
2.2 Global configuration
1. Enable the custom hook parameter vim / etc/gitlab/gitlab.rb # of gitlab and configure it as follows: gitlab_shell ['custom_hooks_dir'] = "/ opt/gitlab/embedded/service/gitlab-shell/hooks/custom_hooks" # Uncomment this line The default is to comment 2.mkdir-p / opt/gitlab/embedded/service/gitlab-shell/hooks/custom_hooks/pre-receive.d # create directory 3.touch / opt/gitlab/embedded/service/gitlab-shell/hooks/custom_hooks/pre-receive.d/pre-receive # create file pre-receive 4.chmod 755 / opt/gitlab/embedded/service/gitlab-shell/hooks/custom_hooks/pre-receive.d/pre-receive 5.pre-receive # The contents of the file are as follows: 6.gitlab-ctl reconfigure # reload the configuration of gitlab Make the configuration effective
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.