Open-Source Development is Amazing!

amullagaliev

Amir Mullagaliev

Posted on November 25, 2024

Open-Source Development is Amazing!

Table of Contents

Introduction

This blog post is about Release 0.3. I would like to start with a little introduction, explaining how hard was to find a good issue. For the last Release 0.2 I had spent all my time on huge JavaFX project, I wasn't satisfied at all, for the reason that I had to find and close two issues within days. This time I was almost caught by the same problem, but by the end I served it as good as I could. Let me walk you through the time-line.

First Bad Issue

At the beginning, I have found an issue, where I was supposed to move App Icon from Dock to Tray for macOS users. It sounds really simple. However, project is written in Go which I had never used before. If you are a reader that is familiar with my blogs, you definitely know how often I learn new programming-languages. Going forward, I decided to learn Go lang from scratch.

Let me quickly explain what's this project about. This is Simple, free and efficient ad-blocker and privacy guard for Windows, macOS and Linux.

systray - First Attempt

Fortunately, Go is really simple to learn, so let's proceed to my attempts moving the icon from Dock to Tray.

For the first attempt I tried to implement using systray library that is written in Objective-C. It helps manipulate the macOS system UI and move application from Dock to Tray. I've written the code, using documentation within 2 hours, was so happy. However, I've got an issue related to the other library called wails which helps implement UI also written in Objective-C. Eventually, building the project failed, for the reason that these two libraries conflict because they use the same namings. I had to move forward and try different library/method.

trayhost - Second Attempt

Basically, this library works the same way as systray, and I had the same issue.

Any other library to do this works the same way, so I was stacked.

How I tried to fix it?

I forked systray project and changed the naming that caused the conflict. Imported my fork, as Go allows to import directly using git-url.
Unfortunately, it didn't work at all...

You may check my fork and see the changes: Click me :D

Objective-C - Third Attempt

This time I tried to write my code, using Objective-C and Go lang. After some time, I came up with the solution, but I got this error:

r0      0x0
r1      0x0
r2      0x0
r3      0x0
r4      0x18fef62cb
r5      0x16d28db00
r6      0x6e
r7      0x0
r8      0x1e844b5b5be91e5a
r9      0x1e844b5a36c1ee5a
r10     0x200
r11     0xb
r12     0x0
r13     0x1ff800
r14     0x7fb
r15     0xd3c1205a
r16     0x148
r17     0x202129928
r18     0x0
r19     0x6
r20     0x16d28f000
r21     0x1003
r22     0x16d28f0e0
r23     0x2
r24     0x0
r25     0x16d28ecc0
r26     0x1f9a37000
r27     0x828
r28     0x140001021c0
r29     0x16d28da70
lr      0x18ff3ac20
sp      0x16d28da50
pc      0x18ff02a60
fault   0x18ff02a60
Enter fullscreen mode Exit fullscreen mode

The error message indicates that you are attempting to initialize an NSWindow instance outside the main thread, which is not allowed in macOS applications. It was a huge problem, as I couldn't do it in the main thread, for the reason the rest of functionality wouldn't work.

Conclusion of First Bad Issue

Maintainer and I had a small talk where I'd been explaining everything. Eventually, he agreed that is impossible to implement with current project structure... I didn't finish it, and don't have PR :c

Help Each Other!

Open-source community is brilliant because people tend to help each other. I had only a week to finish, so I asked my friend Theo for help. He sent me couple of the repos that he worked on, and I decided to work on them.

MatterMost

MatterMost is an open source platform for secure collaboration across the entire software development lifecycle. It's pretty popular platform and has tons of issues, huge documentation as for users as for developers. It wasn't hard to contribute to this project.

Issue

This time I have taken something that matches my current skill level, and I don't shoot my foot. It was simple issue found in early mentioned mattermost.

Purpose of The Issue

The purpose of that issue is to fix linter errors for one of the files. I set up the project, and started working on it.

First thing first, I had to run linter and see all the errors. I checked the lines where it occurred, and fixed them all pretty quickly. Eventually, opened a PR.

Back To CLI

I really liked working on CLI tools because it's fun to me. For the second PR I found a project called lumen. Lumen is an instant AI Git Commit message, Git changes summary from the CLI. I really enjoyed working on this project! Unfortunately, the don't have that many issues, but I was lucky enough to get assigned. In addition, this tool is written in Rust, so I had to refresh my knowledge.

Issue Description

I found an issue Add STDIN support for explain command.

What does it mean?

This tool has an option explain which is invoked this way:

lumen explain <sha>
Enter fullscreen mode Exit fullscreen mode

This command explains everything about certain commit, what it changed and why. Example:

Explain DEMO

Pretty useful tool, huh?

My implementation should allow to add functionality to this command:

echo "HEAD" | lumen explain -
Enter fullscreen mode Exit fullscreen mode

So it takes STDIN value from echo, in my example HEAD, and replaces - with that HEAD value.

Implementation

I realized how to implement it. Created condition to check if - instead of sha.

if sha == "-" {
   // Pass `-` as an indicator to read from stdin
   GitEntity::Commit(Commit::new_from_stdin()?)
} else {
   GitEntity::Commit(Commit::new(sha)?)
}
Enter fullscreen mode Exit fullscreen mode

Result

After changing 5 files, I came up with the result:

Image description

Now it has two options:

lumen explain <sha>
Enter fullscreen mode Exit fullscreen mode

and

echo "<sha>" | lumen explain -
Enter fullscreen mode Exit fullscreen mode

Both of these options are working, my implementation added new functionality, and saved previously implemented! Here's my PR.

Conclusion

Last couple of weeks weren't simple, but was fun. I learnt new language Go. Connected with Open-Source community which helped me to find one of the repos that I contributed to!

💖 💪 🙅 🚩
amullagaliev
Amir Mullagaliev

Posted on November 25, 2024

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

Sign up to receive the latest update from our blog.

Related

Open-Source Development is Amazing!
opensource Open-Source Development is Amazing!

November 25, 2024