Package: git-workon
GIT workonDo you often need to clone some project, solve one task and remove it from your filesystem?Are you often afraid that you might leave something unpushed or stashed?Do you like to leave a perfectly clean desk after your work is done?Then this script is for you.InstallationThe package is available onPyPiand can be installed withpip:pipinstallgit-workonUsageConfigurationThe script commands can be fully controlled by CLI arguments, but it is much convenient to have a configuration file
defining most of parameters. There is a specialconfigcommand that will help you to prepare suitable configuration.gwconfig[options]This command will:Create configuration directory if it does not exist. It will use OS-specific config directory, e.g.~/.config/git_workonfor LinuxCopy template configuration file to the configuration directory if it does not existThe configuration file is a simple JSON contains the following parameters:sources- the array of sources from which projects will be cloned. Clone attempts will be done sequentially.
Example:"sources":["https://github.com/<my_username>","git@github.com:<my_username>"]May be overridden by-s/--sourceargument. You can also define multiple sources:-s first second -s thirddir- the working directory. All projects will be cloned to this directory. May be overridden by-d/--directoryargument.~in path is supportededitor- the editor used to open a cloned project or the configuration. May be overridden by-e/--editorargument.
If not specified and-e/--editorargument is not provided, the script will try to use the editor specified by$EDITORenvironment variable. If that variable is not set, the script will tryviandvimconsequentlyConfiguration example:{"dir":"~/git_workon","editor":"vim","sources":["https://github.com/pallets","https://github.com/pypa"]}Start to work on a projectWhen it is time to work on some project, use thestartcommand:gwstart<my_project>[options]This command will:If the project with a given name already exists in the working directory:open it with a configured editorIf the project with a given name does not exist:clone it from git sources into the working directoryopen the project with a configured editorSeegw start --helpfor other available options on how to control the command.Finish your work with a projectWhen you are done with your work, usedonecommand:gwdone[<my_project>][options]This command will:Check for left stashesCheck for unpushed commitsCheck for left unstaged changesCheck for unpushed tagsIf anything from above was not pushed:fail with an error describing what was left unpushedIf everything was pushed:remove a project from the working directoryIf a project name was not passed, the command will try to remove all git repos from the working directory.Seegw done --helpfor other available options on how to control the command.Show all tracked projectsTo list all projects under the working directory, useshowcommand:gwshow[options]This command will check every project status and colorize the output according to it:Clean (everything is pushed) - green colorDirty (something is not pushed) - yellow colorUndefined (not a git project) - white colorSeegw show --helpfor other available options on how to control the command.Bash completionsImplemented as a bash scriptworkon_completions. Currently, it adds completions only for basic commands.
To enable completions, simply copy the script to/etc/bash_completion.d/or copy it anywhere and source when you
need.