Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push contributors towards develop and not to main for PRs #303

Merged
merged 10 commits into from
May 18, 2023
14 changes: 14 additions & 0 deletions .github/workflows/protect_main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: 'Protect Main Branch'

on:
pull_request:

jobs:
check_branch:
runs-on: ubuntu-latest
steps:
- name: Check branch
if: github.base_ref == 'main' && github.head_ref != 'develop'
run: |
echo "ERROR: You can only merge to main from develop. Make sure your PR merges into the right branch."
exit 1
13 changes: 7 additions & 6 deletions CONTRIBUTIONS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,25 @@ In your terminal, clone the repo on your local machine, and move into the newly
cd Tangelo

From the perspective of your local clone, your fork is called the ``origin`` remote.
Let's synchronize your fork with the main Tangelo repo by adding the latter as the upstream remote, and then update your local ``main`` branch:
Let's synchronize your fork with the main Tangelo repo by adding the latter as the upstream remote, and then update your local ``develop`` branch:

.. code-block:: shell

git remote add upstream https://github.com/goodchemistryco/Tangelo.git

git fetch upstream
git checkout main
git merge upstream/main
git checkout develop
git merge upstream/develop

Note: we here suggest the ``develop`` branch, as this is where contributions will be merged. No one should be merging directly to ``main``, unless it is to sync it with ``develop`` once in a while, and just before a new version release.

**2. Work on your own developments**

Create your development branch, based on the ``main`` branch (or the current development branch listed on the `DevBranch badge <./README.rst>`_)
Create your development branch, based on the ``develop`` branch (or the current development branch listed on the `DevBranch badge <./README.rst>`_, if different)

.. code-block:: shell

git checkout main -b your_branch_name
git checkout develop -b your_branch_name

where ``your_branch_name`` is the name of your own development branch, preferably related to what you will be working on.
Let's assume you've made some changes and committed them with ``git commit``, and that you'd like to push them to your fork (which is referred to as "origin"):
Expand All @@ -72,7 +73,7 @@ Let's assume you've made some changes and committed them with ``git commit``, an

**3. The Pull Request (PR)**

Now when you go to https://github.com/goodchemistryco/Tangelo, you should be able to create a pull request from the branch on your fork to a branch on the main Tangelo repo. Give your pull request a name and briefly describe what the purpose is and include a reference to the associated issue if there's one.
Now when you go to https://github.com/goodchemistryco/Tangelo, you should be able to create a pull request from the branch on your fork to a branch on the main Tangelo repo. Give your pull request a name, verify that the destination branch is ``develop`` (not ``main``), and briefly describe what the purpose is / include a reference to the associated issue if there's one.
Several Tangelo users will receive a notification, and will review your code and leave comments in the PR. You can reply to these comments, or simply apply the recommended changes locally, and then commit and push them like above: it automatically updates your PR.
If there are conflicts, you can solve them locally and push, or directly through Github.

Expand Down