DEV Community

Abhinav
Abhinav

Posted on

Commitment

It's been 3 weeks and the word open-source and to practice has become part of my life. I have taken a short step towards it by contributing in my peer's repository share-my-repo, where I added a feature. As everybody says every step count so this is out of the whole journey.
I tried many tools and played with many commands. Stackoverflow and other guiding websites became my favourite. I did it by skimming through the code and then filling the issue requesting to add the feature into it.

Once the issue was filed, I forked the repo, cloned it locally, and created a new branch:

git checkout -b issue-X

Then, In cli.py, I added a new --recent/-r flag using the existing click options. This was straightforward once I understood how the CLI arguments were being handled.

The main technical challenge was in file_processor.py
. I created an is_recent(file, days=7) helper function that checks the file’s last modified timestamp with Python’s os.stat().st_mtime.

The logic works by comparing the file’s modification time to the current time (via time.time()), and converting the difference into days. If the difference is less than or equal to 7, the file is considered “recent.”

Edge cases included:

Non-existent files → handled with a try/except FileNotFoundError.

Empty repositories → the function returns an empty list gracefully.

Finally, in formatter.py, I added a new section "## Recent Changes". This section outputs each recent file along with how many days ago it was modified.

`Example:

## Recent Changes
- src/main.py (modified 2 days ago)
- README.md (modified 5 days ago)`
Enter fullscreen mode Exit fullscreen mode

I updated the README.md to explain the new flag, its usage, and examples.

Top comments (0)