DEV Community

Cover image for How to Contribute to a Open-Source Rust Project as Beginner
Nathan
Nathan

Posted on

How to Contribute to a Open-Source Rust Project as Beginner

Rust has become a popular programming language and, according to Stack Overflow, has been the most loved language for consecutive years.

I will not repeat myself. For mastering RUST, a lot of hands-on is needed, check my previous article for more information.
Open source is a great way for beginners to get involved in coding and development. By contributing to open source projects, beginners can learn from more experienced developers and gain valuable experience. Open source also provides a great way for beginners to collaborate with others and build something that is useful for the community.
This article will help you to understand how to contribute to an open-source project from the beginning.

First Contributions

Firstly you need to chose a RUST project according to your level.
Please ensure that you have git installed on your machine,
If you don't have please follow this article.
Then note that you are going to need RUST installed on your computer.

Fork

Fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project.

Most commonly, forks are used to either propose changes to someone else's project or to use someone else's project as a starting point for your own idea.
Go the main page's of the open source project and check the "Contribute.md" this file give you all you need to know for contributing, generally also indicates which branch is dedicate for contributing.
Image description

Clone the repository

We are going to work locally on the project, so we need to clone the forked repository.
Clone is used to create a copy of a git repository. Clone creates a local copy of the remote repository.
git clone https://github.com/YOUR_USERNAME/project_name.git

Create your own branch

There are a few reasons why you might want to develop on a separate branch:

  1. It allows you to keep your development work separate from your main branch (usually "master"). This is helpful if you want to experiment with new features or ideas without affecting the stability of your main branch.

  2. It allows you to share your work-in-progress with others without having to merge it into the main branch. This can be helpful for collaboration or feedback.

  3. It allows you to easily "revert" your changes if you decide that they're not good after all. This can save you a lot of time and hassle compared to trying to fix things on your main branch.

Go to the cloned repository:
cd project_name

Create a new branch.
git switch -c your-new-branch-name

Let's contribute and make your own change

Please read carefully the Contribute.MD and check what the company's needs are.
Let's take as example CherryBomb (Rust open source API security project).

Image description

I wrote a simple function that checks an element from the OAS(open api specification) file.
Image description
Add the function to the check.rs file.
Image description
In all only two files has been changed.

Now add those changed to your branch.
git commit add -A
Now commit those changed.
git commit -m " my first contribution"

Push

For the moment, your changes are only locally saved. We are going to save them in the cloud, in our case,to forked repository.
git push origin -u <add-your-branch-name>

Final step, Submit.

In order to finish your contribution you need to pull your code.
What is a pull request?
A pull request is a way to request that someone else (usually a project maintainer) pull changes from your branch into their branch. This is usually used when you have made changes that you want to contribute to a project, but are not ready to merge them into the main branch yet.

So go to your repository on GitHub, click on "Pull request" button on the top, then "new pull request".
Image description
Submit.
Image description

Now the maintainer will audit and review your pull request. If there is no need to modify something, your code will be merged into the master branch, and you will get a notification email.

What is the next step?

If you liked to read this article don't hesitate to give us a star at our GitHub repo.
Stay tuned. In my next article I will give you a list of beginner open-source repos to contribute to.

Between this, you can contribute to CherryBomb.

If you have any idea, or questions let's talk at our Discord Server: https://discord.gg/Krd4sNkk.

Top comments (2)

Collapse
 
jmalvarez profile image
José Miguel Álvarez Vañó

Thanks for the post. There is one small error. git switch already switches to the new branch, so git checkout is not needed.

Collapse
 
nathan20 profile image
Nathan

Thank I will update