Design a site like this with
Get started

Remotes and Merges

For our fourth lab we are asked to add a feature to one of ours peers’ repositories which allows a user to pass a file which contains a list of URL patterns to ignore. Except this time you cant submit a pull request but tell the maintainer of the upstream repo to merge it themselves from your branch.

Merging a New Feature to My Repository

Matthew submitted an issue for a feature request that they wanted to implement into WISA detailing that they forked my repo and would begin to work on it. After sometime passed I got an update saying that they concluded the work and tested and handed it off to me to check if I was satisfied with what had been done. I added the branch the feature was added to to my remotes on my repository and pull the changes and check the code. Afterwards, I ran some tests and the ignore feature worked perfectly so I begun the merging process. I checkout to master and merge Matthew’s branch into mine and push it to master.

Adding a Feature to Someone Else’s Project

This time around all the Go projects had other students working on them so I switched it up and worked on Devansh’s JavaScript project. I began by creating an issue on their repo detailing the feature I wanted to add. First, I forked the fireLinker repo and created a new branch to add the feature to.

Adding the feature itself wasn’t hard because JavaScript has a bunch of useful functions to aid with the process. The main part of the feature is the following code:

let ignoreData = await fs.readFile(path.normalize(ignoreDoc), "utf8"); // gets the data from the ignored patterns document
ignoreData = ignoreData.replace(/^#.*(\r?\n|\r)/gim, "");

let ignorePatterns = [];

// loops through all 'link_reg' matches and pushes to an array of regexes
ignoreData.match(link_reg).forEach(url => {
  let retainDotsUrl = url.replace(/\./gim, "\\.");
  ignorePatterns.push(new RegExp(retainDotsUrl+".*(\r?\n|\r)?", "gim"));

ignorePatterns.forEach(regex => data = data.replace(regex, ""));

Essentially, I took the string containing all the URLs before mapping them into a list/array and by converting the URL patterns from the ignore file into a list of regular expressions that I would loop through and remove all matches of each expression from the original data string. After looping through all the expressions the data should only contain valid URLs and is then processed.

Once the feature was implemented, I tested it to ensure it worked and then pushed the work to my branch and provided an update on the issue I created detailing how I went about implementing the feature and provided some small data sets to test on. Devansh was okay with the changes and merged the work after testing the feature and closed the issue.

This lab cleared up how commit history can work across forks and how you don’t have to have to create PRs to become a contributor on a repo because if the maintainer happens to see the work you did and likes it they can merge it in themselves which is neat.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: