palpatine supports config file in JSON format
Tags: opensource, cpp, tutorial, showdev
Published: 2022-10-07 23:59:15

## Reflection

Over the last 5 weeks I have been slowly adding new features to my static site generator [palpatine](https://github.com/batunpc/palpatine). This week too palpatine got a new feature. However, not just that, this week I also learned more interesting features that GitHub has to offer: using tracking branches and testing via [remotes](https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches). Even though I have been using GitHub for about a year now, I had no idea about tracking branches and remotes. This was very interesting but something that also took me a little while to develop the muscle memory to type out intuitively. 

## Constant Collaboration 

This week there were a lot of collaborative efforts between me and my lab partner. Our task was to add a –config feature so that the users can specify all their SSG options in a JSON formatted configuration file instead of having to pass them as command line arguments. For example, consider the following config file, ./ssg-config.json:
```json
{
  "input": "./site",
  "output": "./build",
  "stylesheet": "https://cdn.jsdelivr.net/npm/water.css@2/out/water.css",
  "lang": "tr"
}
```
I worked on my partner’s static site generator, [rwar](https://github.com/saminarp/rwar), to implement this feature and she worked on my static site generator – palpatine. I was easily able to do this in rwar which is written in Python. However, I realized that this feature was much harder to implement on palpatine which is written in C++. Samina reached out multiple times seeking help for the broken Cmake configurations and for helping in integrating the [nlohmann/json](https://github.com/nlohmann/json) library.


## Creating a Draft Pull Request

Until now, I had only worked with pull requests but never with [draft pull requests](https://github.blog/2019-02-14-introducing-draft-pull-requests/). After forking the repo and creating a branch to push all my changes in, I created a draft pull request. I added all commits here until the feature was complete and marked it as ready to review for the repo owner. 

## Git Fetch and Tracking Branches

While I was creating a draft pull request for the --config feature for rwar - I had the same done for me. When the --config feature was ready for review for palpatine. I did the following steps:
```sh
$ git remote add <name-of-remote> <https://git-url-of-other-student-fork.git>
```
Then....

```sh
$ git fetch <name-of-remote>
```
The fetch was done to get the latest changes from the remote repo.
In order to update the local tracking branch in the process to see any changes being made we can always do this: 
```sh
$ git checkout <issue-name>
$ git pull <name-of-remote> <issue-name>
```

After my review when all changes were satisfactorily done, I merged the work to my main branch and this automatically closed the pull request. 

## For Next Time...

I am sure there are lots of opportunities down the road for me to use tracking branches and remotes. My current focus is really on contributing as much as I can to Hacktoberfest and use some of my newly learned GitHub skills there. 

## Useful Links

| contributor | SSG | Issue | PR | Merged commit |
| --- | --- | --- | --- | --- |
| [saminarp](https://github.com/saminarp) | [palpatine](https://github.com/batunpc/palpatine) | [issue #11](https://github.com/batunpc/palpatine/issues/11) |  [pull #12](https://github.com/batunpc/palpatine/pull/12) | [c08c63a](https://github.com/batunpc/palpatine/commit/c08c63a4003df9d0761ab227599620b60c110af3)
| [batunpc](https://github.com/batunpc)| [rwar](https://github.com/saminarp/rwar) | [issue #11](https://github.com/saminarp/rwar/issues/11) | [pull #12](https://github.com/saminarp/rwar/pull/12) | [f3551c0](https://github.com/saminarp/rwar/commit/f3551c0b7f1e1fbef80801cb3117f64539ca9ec9)