Skip to content
/ polf Public

Quickly push a file with the content copied from the clipboard to a remote repository.

Notifications You must be signed in to change notification settings

fn-r/polf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

Push One Line File (POLF)

AboutUsed OnTechnology StackOptimizationsLesson LearnedSetupHow To

About

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.

POLF

Used On

Technology Stack

PYTHON BADGE

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.

Optimizations

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: _

Lesson Learned

  • subprocess: subprocess is used to replaced Python deprecated os module. The os 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.

Setup

  1. Make sure Git is already setup and configured
    $ git config --global user.name "Your Name"
    $ git config --global user.email "[email protected]"
  2. 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
  3. If it is not installed, you can install it with the following commands
    $ sudo apt-get update
    $ sudo apt-get install python3
  4. Go to your local repo
  5. Clone this repo into your local repo
    $ git clone https://github.com/fn-r/polf.git
  6. Cut the roots of this repo with the following command
    $ rm -rf polf/.git
  7. Go to polf > main.py and change file_path according to your remote repo path
  8. Create .gitignore file (ignore this step if you already have it)
  9. In .gitignore, add the following line
    /polf
    

How To

  1. Copy content
  2. Run POLF in the terminal (make sure you are in your local repo) using the following command:
    $ python polf/main.py
  3. Enter file name
  4. Enter commit message

About

Quickly push a file with the content copied from the clipboard to a remote repository.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages