|
| 1 | +# Contribution Guidelines |
| 2 | + |
| 3 | +## Creating new branch to work on the repository |
| 4 | + |
| 5 | +1. Always create a new branch from the current main branch when you start to work on a new feature. |
| 6 | +2. In the terminal, this can be in the VSCode terminal. Make sure you are in the main branch. |
| 7 | + |
| 8 | + ```bash |
| 9 | + git checkout main |
| 10 | + ``` |
| 11 | + |
| 12 | +3. Now we want to make sure that the main branch is up to date. |
| 13 | + |
| 14 | + ```bash |
| 15 | + git pull |
| 16 | + ``` |
| 17 | + |
| 18 | +4. Now we want to create a new branch from the main branch. You can name the branch whatever you want, but it is recommended to use a descriptive name. For example, if you are working on new features, feat/new-feature-name is a good name. If you are fixing some issues, fix/issue-name is a good name. |
| 19 | + |
| 20 | + ```bash |
| 21 | + git checkout -b "branch-name" |
| 22 | + ``` |
| 23 | + |
| 24 | +5. Now you are set to start working on the new features. |
| 25 | + |
| 26 | +## Committing changes |
| 27 | + |
| 28 | +1. When you are done with the changes, or if you want to save the progress, you can commit the changes. |
| 29 | +2. In the terminal, first you want to add the changes to the staging area. The `.` means all files in the current directory. |
| 30 | + |
| 31 | + ```bash |
| 32 | + git add . |
| 33 | + ``` |
| 34 | + |
| 35 | +3. Now you can commit the changes. It's recommended to use a descriptive commit message. For example, we use this format in our integration-apps repo: `type(scope): [ticket-id] message`. |
| 36 | +
|
| 37 | + ```bash |
| 38 | + git commit -m "commit message" |
| 39 | + ``` |
| 40 | +
|
| 41 | + - For this project, the type is probably just 'feat' or 'fix'. |
| 42 | + - The scope is to show what part of the project you worked in, this can be as broad as HubSpot, or SalesForce, or as specific as SF-AAL. |
| 43 | + - If there are jira tickets, you can put it in the ticket-id portion. Our gitlab has an integration to link with Jira. |
| 44 | + - Be descriptive in the message, but keep it short and concise. |
| 45 | + - There are not strict rules on the format currently, but it's recommended to follow the format above. |
| 46 | + |
| 47 | +## Pushing changes to the remote repository |
| 48 | + |
| 49 | +1. Once you are done with the changes and all of the changes are committed, you can push the changes to the remote repository, or back to gitlab server. |
| 50 | +2. Use the following command to push the changes to the remote repository. |
| 51 | + |
| 52 | + ```bash |
| 53 | + git push origin "branch-name" -u |
| 54 | + ``` |
| 55 | + |
| 56 | + - origin is the name of the remote repository, this should be pointing to the main gitlab repository. |
| 57 | + - if someone else has already pushed to the remote repository with the same branch name, you will run into contacts. You can rename your branch by checking it out as a different branch and then push again with the new name. |
| 58 | + |
| 59 | + ```bash |
| 60 | + git checkout -b "new-branch-name" |
| 61 | + ``` |
| 62 | + |
| 63 | + - the `-u` flag is to set the upstream branch. This allows you to commit new changes to the same branch if the review process asked for changes. Then you can just use `git push` to push the changes. |
| 64 | + |
| 65 | +## Creating a merge request |
| 66 | + |
| 67 | +1. Once you have pushed the changes to the remote repository, you can create a merge request to the main branch. |
| 68 | +2. In the gitlab website, go to the repository page and click on the "Merge Requests" tab. |
| 69 | +3. Click on "New merge request". |
| 70 | +4. Select the source branch and the target branch. The source branch is the new branch you just pushed. The target branch is the main branch. |
| 71 | +5. Click on "Create merge request". |
| 72 | +6. Now you can review the changes and merge the changes to the main branch. Currently, there are no strict reviewing rules, but you should always ask for another person to review the changes. |
| 73 | + |
| 74 | +## After the merge request is merged |
| 75 | + |
| 76 | +1. The remote branch should be deleted automatically if you did not change the merge request settings. |
| 77 | +2. You can now go back to your local main branch and pull the latest changes with the following command: |
| 78 | + |
| 79 | + ```bash |
| 80 | + git checkout main |
| 81 | + git pull |
| 82 | + ``` |
| 83 | + |
| 84 | +3. You should now delete the merged local branch with the following command: |
| 85 | + |
| 86 | + ```bash |
| 87 | + git branch -D "branch-name" |
| 88 | + ``` |
| 89 | + |
| 90 | + - The `-D` flag is to force delete the branch. Sometime git does not recognize the local branch as merged, so we have to use the force flag. |
| 91 | + |
| 92 | +4. It is important to never start working on a new feature from an old branch. Always create a new branch from the main branch. |
| 93 | + |
| 94 | +## Viewing the merged results |
| 95 | + |
| 96 | +1. Merging the request will trigger an internal build. You can review the result usually in a few minutes. |
| 97 | +2. If the build is successful, the changes will be deployed to the test environment. You can review the changes in the [gitlab pages site](http://integration.pages.git.ringcentral.com/ringcentral-integration-docs/). |
0 commit comments