• About • Used On • Technology Stack • Optimizations • Lesson Learned • Setup • How To •
POLF can be used to quickly push a file with the content copied from the clipboard to a remote repository.
POLF was created after I started to do codewars to improve my coding skills. Code challenges are sorted from the lowest 8 kyu
to the highest 1 kyu
difficulties. Most of the 8 kyu
challenges can be solved in one line.
Create a new file, copy the solution, paste the solution, stage the file, commit, include the message, and push is too many steps to do for a file containing only one line.
Using POLF the steps are reduce to two steps, create a new file and include the commit message.
My learning for this project is by purposely not using GitHub API and other libraries that require installation as I have made this project for those that just started to code.
I may further improve this project by utilizing the new Python standard library, ConfigParser. This way it would prompt user for the local path only during setup. In order to change this path, however, I would also need to add a menu similar to this:
----- Main Menu -----
1. Push to Remote Repo
2. Edit Local Path
Enter your choice: _
- subprocess:
subprocess
is used to replaced Python deprecatedos
module. Theos
module is susceptibility to shell injection, so it is best to avoid using it. - It's risky to use deprecated methods, make sure to check Python documentation to check for the modern approach.
- Make sure to include error checking. Some special characters are not allowed as the file name.
- Make sure Git is already setup and configured
$ git config --global user.name "Your Name" $ git config --global user.email "[email protected]"
- Python 3.5 and above is needed to run the script. You can check Python 3 is installed and its version with the following command
$ python3 --version
- If it is not installed, you can install it with the following commands
$ sudo apt-get update $ sudo apt-get install python3
- Go to your local repo
- Clone this repo into your local repo
$ git clone https://github.com/fn-r/polf.git
- Cut the roots of this repo with the following command
$ rm -rf polf/.git
- Go to
polf
>main.py
and change file_path according to your remote repo path - Create .gitignore file (ignore this step if you already have it)
- In .gitignore, add the following line
/polf
- Copy content
- Run POLF in the terminal (make sure you are in your local repo) using the following command:
$ python polf/main.py
- Enter file name
- Enter commit message