This document is the best practice guide that contains the rules to follow when working with AsyncAPI repositories.
Each contributor and maintainer in AsyncAPI must follow this workflow:
- Work on forked repositories.
- Create branches on the fork and avoid working directly on the
master
branch.
A fork is a copy of the repository from which you raise pull requests to propose changes to the original repository. The unified AsyncAPI contribution workflow that bases on forks allows both the members of the AsyncAPI organization and the external contributors to contribute code and content through the same process. This keeps the main repositories branches clean as contributors create branches only on the forked repositories.
The document refers to the original repository as the upstream repository and to the forked repository as the origin repository. We assume you already have a fork of the upstream and you git clone
it already.
If you perform such configuration for the first time, it is recommended to do it manually to understand all the steps. Next time you do it you can write a script for it or use something like this
Configure a remote
repository that points to the upstream repository. This allows you to synchronize changes you make on the fork with the original repository.
In the terminal, navigate to the location of your fork and perform the following steps:
-
Run the
git remote -v
command to list the current configured remote repository for your fork. The result is as follows:origin https://github.com/{your-username}/{your-fork}.git (fetch) origin https://github.com/{your-username}/{your-fork}.git (push)
See the example:
origin https://github.com/i000000/asyncapi.git (fetch) origin https://github.com/i000000/asyncapi.git (push)
-
Specify a new remote upstream repository to synchronize with the fork:
git remote add upstream https://github.com/{original-owner}/{original-repository}.git
See the example:
git remote add upstream https://github.com/asyncapi/asyncapi.git
-
Run the
git fetch upstream master
command to fetch all the changes from upstream/master branch. -
Set up the local
master
branch to track the remotemaster
branch from the upstream repository:git branch -u upstream/master master
Now, each time you rebase or check out the master
branch, you refer to the master
branch of the upstream repository. In other words, when you create a branch from local up-to-date master
means creating a branch from latest upstream master
.
To verify that your local master
branch points to the upstream/master
, run the git branch -vv
command. The result is similar to the following:
* master c2226e0 [upstream/master] Update the README.md document
In case you are a contributor who suggests minor changes using GitHub UI, it is recommended to use a Pull bot. This bot keeps your fork up to date by creating and merging a pull request with latest changes into the master
branch of your fork.
After you set up your fork, start contributing code and content.
Follow these steps:
-
Create a branch on your fork.
-
Commit changes. Always provide clear commit messages to track commit changes easier.
-
Push the changes to the remote forked repository.
NOTE: Before you push local changes, make sure you are on the branch you are currently working on. Do not push any changes from the
master
branch.If you push local changes from the terminal to your remote fork for the first time, use this command:
git push -u origin {branch-name}
Use the
git push
command to push any further commits made on your local branch to a remote repository. -
Create a pull request from the branch of your forked repository to the
master
branch of the upstream repository and wait for the maintainers' review.