Protecting the master branch

As we previously discussed, since the master branch represents the stable version of our smart contract, we need to properly control how code changes are introduced.

We will now configure our repository to ensure that only pull requests can alter the content of the master branch. To achieve this, the first step is to open a browser and point it to your Git repository.

Once the web page has loaded, go through the following steps:

  1. Looking at the top tabs of the Git pages, you should be able to locate the Setting tab
  2. Once you click on it, a side menu should appear on the left-hand side of the page
  3. Select the Branches menu item and you should be able to see the Protected branches section
  4. Select the master branch from the dropdown

This will open the page that contains all the options we need to set to properly protect the master branch.

The content should be set to the following:

This first set of options, circled in red, ensures that every change to the master branch is done through pull requests and that the approval process can only be done on up-to-date code, and by the code owners only.

We have highlighted this section in red because, while these are very important when working in teams, it should be disabled for our exercise. Essentially, GitHub will not let you review your own pull requests and will prevent you from completing the steps later on.

The second set of options provides the ability to define checks to be performed before allowing the code to be merged. We will shortly be adding one of these checks in the next section.

The final option also ensures that even administrators of the repository need to follow the process of pull requests when modifying the code.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.104.153