DEV Community

Thanh Tien Phat Nguyen
Thanh Tien Phat Nguyen

Posted on

Remotes, Commits and Merges! Is that a long distance relationship?

This week has been such a hectic whirlwind for me. Stacks of assignments from different classes are waiting to be finished by me. But I still find it enjoying while working with opensource. Even though sometimes I find committing to others (repo) extremely difficult but I still have a butterflies while working. Maybe I'm in love...
Alt Text

Ideas of new feature

  • Users want to be able to run our link checker tools and be able to include an extra argument, a file of URL patterns to be ignored.
  • This week's feature will add the ability to exclude URLs from our check based on a URL pattern file.

What I did

I filed an issue and forked the repo from Pedro's github

A forked repo allows me to work as an remote and modify the code as I please without interfering the original repo.

Create a readIgnoredFile

const readIgnoreFiles = async (filePath) => {
  const urlRegex = /(((http|https):\/\/)|(www\.))([\w+\-&@`~#$%^*.=\/?:]+)/gi;
  let urlList = [];

  const data = await fs.promises.readFile(filePath, "utf8");

  let check = data.startsWith("#")
  if (check) {
    urlList = data.toLowerCase().match(urlRegex);
    urlList = Array.from(new Set(urlList));
    if (urlList.length != 0)
    {
      return urlList;
    }
    else{
      let message = "There is no valid URLs in the file."
      return message;
    }
  }
  else{
    let message = "Your ignore test file is not valid."
    return message;
  }

}
Enter fullscreen mode Exit fullscreen mode
  • The code above will validate the file. If there is no comment which starts with "#", the file is invalid.

  • Also, it will return any url grabbed from the "IgnoredTestFile".

Create a removeAnyURLsStartwith function

const removeAnyURLsStartwith = (urls, urls_condition) => {
  for (let i = 0; i < urls_condition.length; i++){
    for (let j = 0; j < urls.length; j++)
    {
      if (urls[j].startsWith(urls_condition[i]))
      {
        urls.splice(j,1);
      }
    }
  }
  return urls;
}
Enter fullscreen mode Exit fullscreen mode
  • This function will remove the URL that starts with any URL declared in urls_condition. For example:
  • https://www.google.com/ is in urls_condition
  • https://www.google.com/search?... will be eliminated since it starts with https://www.google.com/

Push my work to the forked repo and ask for merge from the repo owner

  • After pushing my work to the branch I created, asking for feedback and merge from the repo owner is necessary.

Difficulties while working

On the contributor's side

There are times I find it difficult to understand other's code

  • Even the code was written by me, after a while it still takes time for me understand it. Let alone other's code.

On the repo owner's side

Manually merge branch worked by others

  • The branch worked by others sometimes take years to resolve conflict.

Conclusion

  • To be honest, working with others' projects is actually interesting.
  • I can learn from the way they code, organize their structure. Also, I can learn how people manage to approach a specific problem while I have a different one. It's like looking from different perspectives.
  • Lastly, COMMUNICATION! COMMUNICATION! COMMUNICATION! That makes everything work.

Latest comments (0)