<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Pedro E.</title>
    <description>The latest articles on DEV Community by Pedro E. (@pedroer).</description>
    <link>https://dev.to/pedroer</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F335369%2F16fc46a3-a49b-4965-a29e-51c092fe0c67.png</url>
      <title>DEV Community: Pedro E.</title>
      <link>https://dev.to/pedroer</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pedroer"/>
    <language>en</language>
    <item>
      <title>Not Allowing Modifications to a File - GITLAB CE</title>
      <dc:creator>Pedro E.</dc:creator>
      <pubDate>Fri, 16 Oct 2020 18:46:24 +0000</pubDate>
      <link>https://dev.to/pedroer/not-allowing-modifications-to-a-file-gitlab-ce-aic</link>
      <guid>https://dev.to/pedroer/not-allowing-modifications-to-a-file-gitlab-ce-aic</guid>
      <description>&lt;p&gt;Sometimes you do not want devs to modify some files in your GIT repo, such as config files, CI/CD files, whatever.. To do that GITLAB EE (Paid version) has an option in the repo/general level but GITLAB CE (Community Edition) does not. &lt;/p&gt;

&lt;p&gt;We can achieve that in a easy way, by adding a file to our Self Hosted Community Edition Gitlab Server.&lt;/p&gt;

&lt;p&gt;Go to your server and find your &lt;strong&gt;“git-data”&lt;/strong&gt; folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~/git-data/repositories/GROUP_NAME/REPO_NAME.git/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we need to create a folder called &lt;strong&gt;“custom_hooks”&lt;/strong&gt; .&lt;br&gt;
Access the new folder and add a file inside it with the name &lt;strong&gt;update&lt;/strong&gt;.&lt;br&gt;
We are going to use an example to not allow modifications to the “gitlab-ci.yml” file.&lt;/p&gt;

&lt;p&gt;Copy the following content to the file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash

refname="$1"
oldrev="$2"
newrev="$3"
result=0

if ! [ "$oldrev" = "0000000000000000000000000000000000000000" ] ; then
    excludes=( ^$oldrev )
else
    excludes=( $(git for-each-ref --format '^%(refname:short)' refs/heads/) )
fi

commits=`git rev-list $newrev "${excludes[@]}"`

for commit in $commits
do
  fileci=`git show --pretty="" --name-only $commit|grep gitlab-ci`
  if [ "$fileci" != "" ] ; then
    echo "####################################################################################"
    echo "Error: THE FILE GITLAB-CI.YML MUST NOT BE UPDATED !!"
    echo "CHECK WITH THE GITLAB ADMINISTRATOR IF YOU WISH SO"
    echo "####################################################################################"
    result=1
  fi

done

exit $result

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So here everytime someone tries to push commits to gitlab that contains this specific file with the name gitlab-ci an error will be presented to the user not allowing that push.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
