Merge branches into Master

isabellaliu77

Isabella Liu

Posted on October 12, 2020

Merge branches into Master

For lab 3 we are required to implement two more features for our little command-line tool which is used to check if the links in a file are reachable or not. I need to admit it has been a tough week for me. The content is not that hard to understand, but I made some tough choices myself, which makes me regret the whole week.
My friend told me to choose easier features to complete the lab, like adding exit codes, etc., however, I decided to choose the one asking to allow JSON output by adding -j or --j flag as arguments. I had been overconfident thinking this one is also an easier one, and life has taught me a lesson through the hard way.

The first feature I chose is to allow the environment variable CLICOLOR to determine the appearance of the output. This one is easy and there is not much struggling part when implementing this feature. I first filed an issue myself, issue-8, and then created a branch issue-8 to complete this task using

git checkout -b issue-8 master
Enter fullscreen mode Exit fullscreen mode

After completing this feature, I changed the working branch back to master and merged branch issue-8 into master, the detailed changes can be checked here.

git checkout master
git merge issue-8
Enter fullscreen mode Exit fullscreen mode

Here comes the fun/struggling part. The second one I chose is to allow JSON output by passing an argument like -j or --json. I expected this one to be a simple one as well since I have implemented other flags in my program. However, I was wrong. I filed an issue called issue-9, then I created a branch for issue-9, of course before I merged issue-8 into master(hoping to have some conflicts when doing the second merge and learn from that). I regretted for several days for making this choice but don't want to surrender this early. Sometimes I am a last-minute player, especially when I am hoping I can do something perfectly but realize the difficulty of doing it. There were so many conflicts with my former logic if I want to add the -j or --json flag. I cannot support multiple files checking using my old logic if I want the json output flags, because any flag would be treated as a file name. I don't want to delete this feature just to add a new one. I was stuck. I checked how others do it and saw they made the file names as a flag, so when trying to run the program, they need to obey format like:

go run urlChecker --file test/urls.txt -j
Enter fullscreen mode Exit fullscreen mode

I don't like it. I got stuck again. For several days I didn't even want to open my editor to work on it. Finally, I figured a way to solve it as below, by checking the first element of the arguments, it is not a smart way I know, but this is the best that I can find.

if os.Args[i][0] != '-' {

                //open file and read it
                content, err := ioutil.ReadFile(os.Args[i])
                if err != nil {
                    log.Fatal(err)
                }
                textContent := string(content)

                //call functions to check the availability of each url
                urls = removeDuplicate(extractURL(textContent))

                //check if there are flags for JSON output or not
                if *jflag {

                    checkURLJson(urls)
                } else {

                    fmt.Println()
                    fmt.Println(">>  ***** UrlChecker is working now...... *****  <<")
                    fmt.Println("--------------------------------------------------------------------------------------------------")
                    checkURL(urls)
                }
            }
Enter fullscreen mode Exit fullscreen mode

Thanks to David's extension of the deadline, I finally finished implementing this feature today, and it was amazing that when I merged branch issue-9 into master, it got merged automatically without torturing me with complicated conflicts at all. Thank you, Git!
I feel so good to conquer the obstacles that I set for myself, and I know there are many other bugs or shortages in my program, but I choose not to tell and to ignore them for now and move on.
Since this is the Hacktoberfest month, and I should finish at least one PR by tomorrow, and I haven't done anything for it yet, I know it will be a long week for me again, and a struggling month as well. I have been and will be anxious and angry more often, but I will not give up.
Please click the links below for the two issues solved through this lab in case you are interested in.
issue-8: implementation
issue-9: implementation

💖 💪 🙅 🚩
isabellaliu77
Isabella Liu

Posted on October 12, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Progress on Automatic Feedback Loop
python Progress on Automatic Feedback Loop

November 29, 2024

A Final Challenge: The Planning Phase
opensource A Final Challenge: The Planning Phase

November 27, 2024

Release 0.4 Planning
opensource Release 0.4 Planning

November 26, 2024

Understanding Open-Source Licenses
opensource Understanding Open-Source Licenses

November 28, 2024