<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: LemonFish</title>
    <description>The latest articles on DEV Community by LemonFish (@lemonfish).</description>
    <link>https://dev.to/lemonfish</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F962727%2F478b638e-0a9c-4717-a7bc-10ef6b9ae49e.jpeg</url>
      <title>DEV Community: LemonFish</title>
      <link>https://dev.to/lemonfish</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lemonfish"/>
    <language>en</language>
    <item>
      <title>Open Source 101: My First PR to Hertz</title>
      <dc:creator>LemonFish</dc:creator>
      <pubDate>Wed, 02 Nov 2022 03:34:26 +0000</pubDate>
      <link>https://dev.to/lemonfish/open-source-101-my-first-pr-to-hertz-2dak</link>
      <guid>https://dev.to/lemonfish/open-source-101-my-first-pr-to-hertz-2dak</guid>
      <description>&lt;h2&gt;
  
  
  Introduce
&lt;/h2&gt;

&lt;p&gt;Recently, with the enthusiastic help of Hertz community friends, I tried to submit a pull request to &lt;a href="https://github.com/cloudwego/hertz"&gt;Hertz(an open-source Golang 's Http high performance framework)&lt;/a&gt; to support Hertz in using Consul for service registration and discovery. Here, I will briefly record the whole process from PR to merged, which is convenient for myself and other friends in need.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The link of PR: &lt;a href="https://github.com/hertz-contrib/registry/pull/8"&gt;feat: Support Hertz to use Consul for service discovery and registration&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Find the open source library you are interested in
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2FfBBf0O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g6ojmae53rpx5h69brae.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2FfBBf0O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g6ojmae53rpx5h69brae.png" alt="Find the open source library you are interested in" width="880" height="459"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Search Github
&lt;/h3&gt;

&lt;p&gt;First of all, we can choose some open source libraries that we are interested in, such as &lt;a href="https://github.com/cloudwego/hertz"&gt;Hertz&lt;/a&gt; mentioned above.&lt;br&gt;
 &lt;/p&gt;
&lt;h3&gt;
  
  
  View Issues
&lt;/h3&gt;

&lt;p&gt;Then looking at the Issues list, we can see that there are 22 issues waiting  to be resolved 👀.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;At present, there are still many interesting issues which may be of interest to you.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gq18FDGf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i3x3hyovsiamz0irwbax.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gq18FDGf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i3x3hyovsiamz0irwbax.png" alt="view issue" width="880" height="116"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Hertz community usually releases some newbie tasks from time to time, so we can start with some simple tasks first.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Among them, we found that one of the issues is that Hertz is preparing to expand the service registration and discovery .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---Ulw2_qM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d87h5hsz4x639rdh44ty.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---Ulw2_qM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d87h5hsz4x639rdh44ty.png" alt="issue list" width="880" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Issue:&lt;a href="https://github.com/cloudwego/hertz/issues/197"&gt;https://github.com/cloudwego/hertz/issues/197&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Looking at the details of this issue, we can see that it includes the following parts&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The description and purpose of the issue&lt;/li&gt;
&lt;li&gt;Where is the code repository?&lt;/li&gt;
&lt;li&gt;Referrable API&lt;/li&gt;
&lt;li&gt;Etc&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ct3qyv99--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r9yuuzaizr54ib6op490.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ct3qyv99--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r9yuuzaizr54ib6op490.png" alt="issue description" width="880" height="616"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;
&lt;h3&gt;
  
  
  Apply for issues
&lt;/h3&gt;

&lt;p&gt;If you find this issue interesting, you can take the initiative to apply to complete the issue.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--izGB055Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4rrk8pcydsixokbq50un.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--izGB055Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4rrk8pcydsixokbq50un.png" alt="Apply for issues" width="880" height="203"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Right now , we have taken the development task for the issue and can work on it next.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;
&lt;h2&gt;
  
  
  Step 2：Wirte the code
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lzMaCmUl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jcvt7mgc86lxxircruqr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lzMaCmUl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jcvt7mgc86lxxircruqr.png" alt="Wirte the code" width="880" height="488"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;
&lt;h3&gt;
  
  
  Fork target repository
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KQGhdmTY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0q0w0a6pndhitufd0v39.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KQGhdmTY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0q0w0a6pndhitufd0v39.png" alt="Fork target repository" width="880" height="113"&gt;&lt;/a&gt;&lt;br&gt;
We first need to fork the repository you want to contribute to your own repository, by forking we can code and not affect the original repository.&lt;br&gt;
 &lt;/p&gt;
&lt;h3&gt;
  
  
  Clone Target Repository
&lt;/h3&gt;

&lt;p&gt;Now our repository contains the repository we forked, we need to clone it to our local machine. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VKXlNdtL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/79ftsxkv7ip1p1g5npli.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VKXlNdtL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/79ftsxkv7ip1p1g5npli.png" alt="Clone Target Repository" width="880" height="295"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone [YOUR HTTPS ADDRESS]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Create a new branch
&lt;/h3&gt;

&lt;p&gt;After cloning, we need to create a new branch for our development.&lt;br&gt;
For new features, we can use feat/xxx as the branch name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout -b [BRANCH NAME]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Develop and push remote branches
&lt;/h3&gt;

&lt;p&gt;Usually the development needs include implementation code, unit test , README, etc&lt;br&gt;
After some development is done, we can start git trifecta&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;git status&lt;/li&gt;
&lt;li&gt;git add [YOUR FILE]&lt;/li&gt;
&lt;li&gt;git commit -m [YOUR COMMIT MESSAGE]&lt;/li&gt;
&lt;li&gt;git push origin [YOUR BRANCH]

&lt;ul&gt;
&lt;li&gt;Before performing git push , you can use git remote to see the name of your remote repository.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7NT70qqX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t7y978mcz5kp7bztdk6k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7NT70qqX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t7y978mcz5kp7bztdk6k.png" alt="git remote" width="880" height="96"&gt;&lt;/a&gt;&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  Unit test combined with github action
&lt;/h3&gt;

&lt;p&gt;Generally, open source libraries will be combined with github actionfor unit test pipeline, the directory of repository  will have .github/workflows/xxx.yml file and some other files . Through these files we can perform our unit test in the pr , push and other stages.&lt;/p&gt;

&lt;p&gt;Therefore, we need to update these files to ensure that we can pass our own unit test .&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a Pull Request
&lt;/h3&gt;

&lt;p&gt;After the push is complete, we can see the following prompt in our fork repository Compare &amp;amp; pull request&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BbeKJo4n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qr935cwiw21319osopbz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BbeKJo4n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qr935cwiw21319osopbz.png" alt="Creating a Pull Request" width="880" height="265"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next we can fill in the information about the PR , usually we need to describe the following information&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What type of PR is this? (feature, fix, etc.)&lt;/li&gt;
&lt;li&gt;What does this PR do?&lt;/li&gt;
&lt;li&gt;Does this PR address certain issues?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9AQza3A3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eg26uvg6w7ywurllazsn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9AQza3A3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eg26uvg6w7ywurllazsn.png" alt="Open a pull request" width="880" height="581"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After filling in the PR information, congratulations, you can create your own PR! 🥰🥰&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  Synchronize changes to the original repository
&lt;/h3&gt;

&lt;p&gt;During our development, there may be other developers who have already merged their PRs into the main branch.&lt;/p&gt;

&lt;p&gt;Then we need to merge the changes into our own development branch.&lt;/p&gt;

&lt;p&gt;Here are some steps you can take : &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add original repository as upstreamrepository
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git remote add upstream [HTTPS]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Get changes from the original repository
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git fetch upstream
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Merge changes
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git merge upstream/main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Resolve conflicts and push to your own development branch
 
## Step 3: Fix the suggestion made by the original repository maintainer
After submitting the PR , we need to make sure that all unit tests pass.
At the same time, there will also be some suggestions from the maintainer of the original repository, which need us to solve&lt;/li&gt;
&lt;li&gt;unit test needs to be completed .&lt;/li&gt;
&lt;li&gt;Doc needs supplements .&lt;/li&gt;
&lt;li&gt;There is a problem with the code implementation .&lt;/li&gt;
&lt;li&gt;Etc
For example: README needs to be added in more detail&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--evu_rp26--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tek21bxay6cpfgzbq4b5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--evu_rp26--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tek21bxay6cpfgzbq4b5.png" alt="The suggestion made by the original repository maintainer" width="880" height="264"&gt;&lt;/a&gt;&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Wait for PR Merged
&lt;/h2&gt;

&lt;p&gt;After all verification steps are completed, you need to wait for the original repository maintainers to approve and merge your pull request .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qCXgdybE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z9dhvw5malmqyn2m51nz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qCXgdybE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z9dhvw5malmqyn2m51nz.png" alt="Wait for PR Merged" width="880" height="510"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When your PR is officially adopted, there will be the following tips.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cAytfVHG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9pz9lmpca6rwshysvbay.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cAytfVHG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9pz9lmpca6rwshysvbay.png" alt="Pull request successfully merged" width="880" height="131"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, congratulations on taking your first step towards open source ! ❤️&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/cloudwego/hertz"&gt;Hertz(an open-source Golang 's Http high performance framework)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.github.com/en/actions"&gt;GitHub Actions Documentation - GitHub Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pythonspeed.com/articles/docker-connection-refused/"&gt;Connection refused? Docker networking and how it impacts your image&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.consul.io/docs/intro"&gt;What is Consul? | Consul by HashiCorp&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>go</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
