GitLab system status is available here and here

Commit 8051316d authored by Anthony Umemoto's avatar Anthony Umemoto
Browse files

v1.3.0

parents e0a0f939 d598166b
#!/bin/bash
function gm_rto {
echo "RUNTIME OPTIONS"
echo " q Quits the program."
echo " c Immediately perform a commit."
echo " t Display the time remaining until the next commit."
echo " v Toggle verbose program output."
echo " s Toggle commit and push summaries."
echo " d dir Changes the git repository being managed."
echo " The file path should be from the current working directory."
echo " b branch Moves to branch. Creates branch if it does not exist."
echo " If no branch is specified, then the branch list will be printed."
echo " f freq Changes the interval between each commit."
echo " If no freq is specified, then the current interval will be displayed."
echo " a file Add a file name to the commit list."
echo " r file Remove a file name from the commit list."
echo " l Display the commit list."
echo " h Display program runtime options."
}
function gm_clo {
echo "COMMAND LINE OPTIONS"
echo " -v Display verbose program output."
echo " -s Silence commit and push summaries."
echo " -p preset Use preset gitmang options."
echo " -x preset Delete the specified preset."
echo " -d dir The file path, from the current working directory, to the repository being managed."
echo " -D dir The file path, from the main directory, to the repository being managed."
echo " -b branch Begins gitmang in branch. Creates branch if it does not exist (default: master)."
echo " -f freq The time interval in minutes between each commit (default: 5)."
echo " -r reps The number of commits to be made before ending (default: 100)."
echo " -R dir Repairs the corrupted repository dir, saving un-committed files."
echo " Path is from working directory."
echo " -B Keeps gm_repair_backup directory after repository repair."
echo " This can be used as a backup in case [-R dir] fails."
echo " file1 ... File names that will be added to the commit list."
echo " -h Display program usage and synopsis."
}
function gm_usage {
echo "GITMANG.SH SYNOPSIS: For more usage information, view the README."
echo " A shell script that commits specified files at a regular interval."
echo ""
echo "USAGE"
echo " $ ./gitmang.sh [-vsBh] [-px preset] [-dDR dir] [-b branch] [-f freq] [-r reps] [file1 file2 ...]"
echo ""
gm_clo
echo ""
echo "OUTPUT"
echo " Prints to stdout: <reps> commit(s) completed over <total time> minute(s)"
echo ""
echo "AUTHOR"
echo " Anthony Umemoto 2022, with debugging assistance from Omar Ahmadyar."
}
function gm_full {
echo "GITMANG.SH SYNOPSIS: For more usage information, view the README."
echo " A shell script that commits specified files at a regular interval."
echo ""
echo "USAGE"
echo " $ ./gitmang.sh [-vsBh] [-px preset] [-dDR dir] [-b branch] [-f freq] [-r reps] [file1 file2 ...]"
echo ""
gm_clo
echo ""
gm_rto
echo ""
echo "OUTPUT"
echo " Prints to stdout: <reps> commit(s) completed over <total time> minute(s)"
echo ""
echo "AUTHOR"
echo " Anthony Umemoto 2022, with debugging assistance from Omar Ahmadyar."
}
# process command line arguments
while getopts hcr opt; do
case "${opt}" in
h)
gm_usage
exit;;
c)
gm_clo
exit;;
r)
gm_rto
exit;;
*)
gm_full
exit;;
esac
done
\ No newline at end of file
# GITMANG v1.2.1
# GITMANG v1.3.0
gitmang can be downloaded off the gitLab web interface, or the gitmang master branch can be pulled using:
......@@ -15,43 +15,53 @@ A shell script for automated git repository management in the command line envir
## PROGRAM FILES
+ gitmang.sh: The shell script for automating git repository management.
+ .gm_usage.sh: Contains usage statements for gitmang.
+ presets.gm: Contains created presets.
+ UPDATE.md: Lists each version of gitmang, and what changes were made.
+ README.md: Explains how to use gitmang.
## USAGE
`$ ./gitmang.sh [-vsBh] [-dDR dir] [-b branch] [-f freq] [-r reps] [file1 file2 ...]`
`$ ./gitmang.sh [-vsBh] [-px preset] [-dDR dir] [-b branch] [-f freq] [-r reps] [file1 file2 ...]`
git must be installed, and gitmang should be run in a UNIX or git bash terminal. gitmang is currently untested in other terminals such as the Windows command prompt, and the macOS terminal. To give executing permissions use:
`$ chmod +x gitmang.sh`
`$ chmod +x gitmang.sh` and `$ chmod +x .gm_usage.sh`
gitmang requires that a terminal window is dedicated to running it. Open a new terminal with:
gitmang requires that a terminal window is dedicated to running it.
`$ ssh <username>@localhost -p <port>`
When quitting the program, use the 'q' runtime option to quit properly. Always remember to quit properly before turning off your machine. If gitmang is unexpectedly ended while it is performing a commit, the local repository may become corrupt. If this happens, use the [-R dir] command to repair the local repository to save un-committed work. However, this command only works if the remote repository URL is uncorrupted. To test if it is, use:
Or open a new git bash window in your gitmang local repository.
`$ git config --get remote.origin.url`
When quitting the program, use the 'q' runtime option to quit properly. Always remember to quit properly before turning off your machine. If gitmang is unexpectedly ended while it is performing a commit, the local repository may become corrupt. If this happens, delete the repository directory with:
If the correct URL is returned, then the repair should work.
`$ rm -rf <dir>`
To make gitmang a more convenient tool to use, presets can be made with the [-p preset] command line option, so that it doesn't require you to repeatedly type the same commands for a project repository you work in often. For example:
and re-clone it with:
`13s_asgn4 -v -s -d ../cse13s/asgn4 -f 10 *.c *.h Makefile README.md`
`$ git clone <repo URL> <dir>`
is a preset that can be made for a cse13s class' assignment 4. This is how the preset will appear in the presets.gm file (preset name first, followed by its options), which contains all created presets and can be editted directly. While presets can be added by typing them into the presets.gm file by hand, it is recommended that the command line option is used instead. This preset can then be used with the same [-p preset] option used to create it:
Alternatively, use the [-R dir] command to repair the local repository to save un-committed work. However, this command only works if the remote repository URL is uncorrupted. To test if it is, use:
`$ ./gitmang.sh -p 13s_asgn4`
`$ git config --get remote.origin.url`
And can be deleted with the [-x preset] command line option:
If the correct URL is returned, then the repair should work.
`$ ./gitmang.sh -x 13s_asgn4`
## OPTIONS
## COMMAND LINE OPTIONS
### GITMANG.SH
`$ ./gitmang.sh [-vsBh] [-px preset] [-dDR dir] [-b branch] [-f freq] [-r reps] [file1 file2 ...]`
`-v` Display verbose program output.
`-s` Silence commit and push summaries.
`-p preset` Use preset gitmang options. Create a new preset if the name does not exist. Display all presets if `ALL` is specified.
`-x preset` Delete the specified preset.
`-d dir` The file path, from the current working directory, to the repository being managed.
`-D dir` The file path, from the main directory, to the repository being managed (recommended for UNIX only).
......@@ -70,6 +80,16 @@ If the correct URL is returned, then the repair should work.
`-h` Display program usage and synopsis.
### .GM_USAGE.SH
`./.gm_usage.sh [-hcr]`
`-h` Display gitmang usage and synopsis.
`-c` Only display gitmang command line options.
`-r` Only display gitmang runtime options.
## RUNTIME OPTIONS
`q` Quits the program.
......
......@@ -2,7 +2,17 @@
Most recent version is listed first.
### v1.2.1 March 24, 2022, 6:50 PDT
### v1.3.0 March 28, 2022 9:40PM PDT
+ Added the [-p preset] command line option.
+ Presets are a way to quickly set up gitmang with options that are regularly used.
+ If the preset name is already defined, then gitmang will begin running using that preset. If the preset name is new, then a new preset will be created. If no preset name is specified, then the list of saved presets will be displayed.
+ Added the [-x preset] command line option to delete to specified preset.
+ Added the presets.gm file, which contains all created presets. This file can be editted directly.
+ Added the gm_usage.sh script, which contains all usage messages for gitmang programs.
+ Minor documentation revisions.
### v1.2.1 March 24, 2022 6:50 PDT
+ Commit count is now correct in program output.
+ *.[file] now behaves properly in the [r file] runtime option.
......
#!/bin/bash
# USAGE MESSAGES ---------------------------------------------------------
function gm_options {
echo "RUNTIME OPTIONS"
echo " q Quits the program."
echo " c Immediately perform a commit."
echo " t Display the time remaining until the next commit."
echo " v Toggle verbose program output."
echo " s Toggle commit and push summaries."
echo " d dir Changes the git repository being managed."
echo " The file path should be from the current working directory."
echo " b branch Moves to branch. Creates branch if it does not exist."
echo " If no branch is specified, then the branch list will be printed."
echo " f freq Changes the interval between each commit."
echo " If no freq is specified, then the current interval will be displayed."
echo " a file Add a file name to the commit list."
echo " r file Remove a file name from the commit list."
echo " l Display the commit list."
echo " h Display program runtime options."
}
function gm_usage {
echo "GITMANG.SH SYNOPSIS: For more usage information, view the README."
echo " A shell script that commits specified files at a regular interval."
echo ""
echo "USAGE"
echo " $ ./gitmang.sh [-vsBh] [-dDR dir] [-b branch] [-f freq] [-r reps] [file1 file2 ...]"
echo ""
echo "OPTIONS"
echo " -v Display verbose program output."
echo " -s Silence commit and push summaries."
echo " -d dir The file path, from the current working directory, to the repository being managed."
echo " -D dir The file path, from the main directory, to the repository being managed."
echo " -b branch Begins gitmang in branch. Creates branch if it does not exist (default: master)."
echo " -f freq The time interval in minutes between each commit (default: 5)."
echo " -r reps The number of commits to be made before ending (default: 100)."
echo " -R dir Repairs the corrupted repository dir, saving un-committed files."
echo " Path is from working directory."
echo " -B Keeps gm_repair_backup directory after repository repair."
echo " This can be used as a backup in case [-R dir] fails."
echo " file1 ... File names that will be added to the commit list."
echo " -h Display program synopsis and usage."
echo ""
echo "OUTPUT"
echo " Prints to stdout: <reps> commit(s) completed over <total time> minute(s)"
echo ""
echo "AUTHOR"
echo " Anthony Umemoto 2022, with debugging assistance from Omar Ahmadyar."
}
# USAGE STATEMENTS -------------------------------------------------------
gm_rto=$(./.gm_usage.sh -r) # runtime options
# COMMAND LINE ARGUMENTS -------------------------------------------------
......@@ -67,12 +21,91 @@ gm_backup=0
gm_files=()
# process command line arguments
while getopts vsd:D:b:f:r:R:Bh opt; do
while getopts vsp:x:d:D:b:f:r:R:Bh opt; do
case "${opt}" in
v) gm_verb=1;; # verbose output
s) gm_sil="-q";; # silence summaries
p) # presets
if [[ ${OPTARG} == "ALL" ]]; then # display all presets
echo "Available presets:"
while read -r line; do
echo "$line"
done < presets.gm
exit
else
# look for preset
while read -r -a gm_preset; do
# if preset is found
if [[ "${gm_preset[0]}" == "${OPTARG}" ]]; then
echo "Preset ${gm_preset[*]}"
# parsing preset options
for (( gm_i=1; $gm_i < ${#gm_preset[@]}; gm_i+=1)); do
case "${gm_preset[$gm_i]}" in
"-v") gm_verb=1;;
"-s") gm_sil=1;;
"-d")
gm_dir=${gm_preset[$((gm_i+1))]}
((gm_i+=1));;
"-D")
gm_dir=${gm_preset[$((gm_i+1))]}
gm_main=1
((gm_i+=1));;
"-b")
gm_branch=${gm_preset[$((gm_i+1))]}
((gm_i+=1));;
"-f")
gm_freq=${gm_preset[$((gm_i+1))]}
((gm_i+=1));;
"-r")
gm_reps=${gm_preset[$((gm_i+1))]}
((gm_i+=1));;
*) gm_files+=( "${gm_preset[$gm_i]}" );;
esac
done
fi
done < presets.gm
# create new preset, dir must be specified so if it is not
# then no preset was found
if [[ $gm_dir == "" ]]; then
./.gm_usage.sh -c
echo ""
echo "Creating new preset ${OPTARG}."
read -p "Preset commands: " gm_preset
echo "${OPTARG} $gm_preset" >> presets.gm
echo "Preset ${OPTARG} created, use preset with ./gitmang.sh -p ${OPTARG}."
exit
fi
fi;;
x) # delete preset
if [[ ${OPTARG} == "" ]]; then
echo "A preset must be specified to delete."
else
# look for preset
gm_i=0
while read -r -a gm_preset; do
if [[ "${gm_preset[0]}" != "${OPTARG}" ]]; then
echo "${gm_preset[*]}" >> .preset_temp.gm
((gm_i+=1))
fi
done < presets.gm
# creates temp file in case there is only one preset
if (( $gm_i == 0 )); then
> .preset_temp.gm
fi
# replaces old presets file
mv .preset_temp.gm presets.gm
echo "Preset ${OPTARG} has been deleted."
fi
exit;;
d) gm_dir=${OPTARG};; # repo directory from working dir
D) # repo directory from main dir
......@@ -103,10 +136,10 @@ while getopts vsd:D:b:f:r:R:Bh opt; do
B) gm_backup=1;; # keep backup
h) # program usage and synopsis
gm_usage
./.gm_usage.sh -h
exit;;
*)
gm_usage
./.gm_usage.sh -h
exit;;
esac
done
......@@ -281,7 +314,6 @@ while (( $gm_reps > 0 )); do
s) # toggle summary silence
if [[ $gm_sil == "-q" ]]; then
gm_sil=""
echo $gm_sil
echo "Unsilenced commit and push summaries."
else
gm_sil="-q"
......@@ -394,7 +426,7 @@ while (( $gm_reps > 0 )); do
echo "Current file names in the commit list:"
echo "${gm_files[*]}";;
h) gm_options;; # runtime options
h) echo "$gm_rto";; # runtime options
*) echo "Failed to execute runtime command.";;
esac
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment