GitLab system status is available here and here

Commit cf4cc2cc authored by Anthony Umemoto's avatar Anthony Umemoto
Browse files

v1.2.0 testing

parent ea24f3ac
......@@ -6,6 +6,8 @@ gitmang can be downloaded off the gitLab web interface, or the gitmang master br
gitmang is an ongoing project, regularly check this repository for bug fixes and improvements. Refer to UPDATE.md for changes between versions.
A second branch called beta is used for testing upcoming versions. It is not recommended to use the gitmang from this branch, as it may be unstable and incomplete.
## DESCRIPTION
A shell script for automated git repository management in the command line environment. It commits specified files at a regular interval. Each commit will have the comment `autosaving progress <timestamp>`.
......@@ -98,6 +100,8 @@ If you encounter a bug, please report it using this form: https://docs.google.co
### UNEXPECTED BEHAVIORS
+ A commit is counted even if nothing is pushed. This is seen in the verbose output, and the program output.
### ARCHITECTURE
+ All variables are prepended with `gm_` to prevent overriding other global variables, but this is still possible since most of the script is not contained within a function.
......
......@@ -51,6 +51,8 @@ function gm_usage {
# all vars are prepended with "gm_" to avoid overriding other global vars
# default options
gm_verb=0
gm_sil=""
gm_dir=""
gm_branch="master"
gm_main=0
......@@ -59,37 +61,43 @@ gm_reps=100
gm_repair=0
gm_backup=0
gm_files=()
gm_verb=0
gm_sil=""
# process command line arguments
while getopts vsd:D:bf:r:R:Bh opt; do
case "${opt}" in
v) gm_verb=1;;
s) gm_sil="-q";;
d) gm_dir=${OPTARG};;
D)
v) gm_verb=1;; # verbose output
s) gm_sil="-q";; # silence summaries
d) gm_dir=${OPTARG};; # repo directory from working dir
D) # repo directory from main dir
gm_dir=${OPTARG}
gm_main=1;;
f)
f) # frequency
if (( ${OPTARG} > 0 )); then
gm_freq=${OPTARG}
else
echo "Interval must be greater than 0, will remain 5 mins."
fi;;
r)
r) # reps
if (( ${OPTARG} > 0 )); then
gm_reps=${OPTARG}
else
echo "Number of commits must be greater than 0, will remain 100."
fi;;
R)
R) # repair directory
gm_dir=${OPTARG}
gm_repair=1;;
B) gm_backup=1;;
h)
B) gm_backup=1;; # keep backup
h) # program usage and synopsis
gm_usage
exit
exit;;
esac
done
......@@ -118,7 +126,7 @@ if (( $gm_repair == 1 )); then
# test if gm_dir is a valid repo
if [[ $gm_url == "" ]]; then
echo "$gm_dir is not a repository, exitting program."
echo "$gm_dir is not a repository or the remote repository URL is corrupt, exitting program."
exit
fi
......@@ -197,22 +205,42 @@ while (( $gm_reps > 0 )); do
# tracking progress
((gm_reps-=1))
((gm_sreps+=1))
# nice formatting
echo "--------------------------------------------------"
# verbose output
if (( $gm_verb == 1 )); then
echo "$gm_sreps commit(s) made in $(basename $(pwd)) on $gm_branch branch."
echo "Current program runtime: $(( $(( $(date "+%s") - $gm_stime )) / 60 )) min(s)."
echo ""
fi
# program input
if (( $gm_reps > 0 )); then
# nice formatting
echo "--------------------------------------------------"
# verbose output
if (( $gm_verb == 1 )); then
echo "$gm_sreps commit(s) made in $(basename $(pwd)) on $gm_branch branch."
echo "Current program runtime: $(( $(( $(date "+%s") - $gm_stime )) / 60 )) min(s)."
echo ""
fi
# program input
read -t $((gm_freq*60)) -p "Input command, use h for options: " gm_cmd gm_arg
case "$gm_cmd" in
q) gm_reps=1;; # quit
v) # toggle verbose output
if (( $gm_verb == 0 )); then
gm_verb=1
echo "Enabling verbose program output."
else
gm_verb=0
echo "Disabling verbose program output."
fi;;
s) # toggle summary silence
if [[ $gm_sil == "-q" ]]; then
gm_sil=""
echo $gm_sil
echo "Unsilencing commit and push summaries."
else
gm_sil="-q"
echo "Silencing commit and push summaries."
fi;;
d) # changed directories
# check for invalid directory
if [[ gm_arg == "" ]]; then
......@@ -236,6 +264,7 @@ while (( $gm_reps > 0 )); do
fi
fi
fi;;
f) # change interval
if (( $gm_arg > 0 )); then
gm_freq=$gm_arg
......@@ -243,14 +272,44 @@ while (( $gm_reps > 0 )); do
else
echo "Interval must be greater than 0."
fi;;
a) # add file
gm_files+=( $gm_arg )
echo "Added $gm_arg to the commit list.";;
if [[ $gm_arg == "" ]]; then
echo "A file name must be specified."
else
gm_files+=( $gm_arg )
echo "Added $gm_arg to the commit list."
fi;;
r) # remove file
if [[ $gm_arg == "" ]]; then
echo "A file name must be specified."
else
gm_i=0
for gm_fname in "${gm_files[@]}"; do
if [[ $gm_fname == $gm_arg ]]; then
unset gm_files[$gm_i]
echo "Removed $gm_arg from the commit list."
else
((gm_i+=1))
fi
done
if (( $gm_i > ${#gm_files[@]} )); then
echo "$gm_arg was not found in the commit list."
fi
fi;;
l) # print commit list
echo "Current file names in the commit list:"
echo "${gm_files[*]}";;
h) gm_options;; # input options
esac
fi
# nice formatting
echo ""
echo "--------------------------------------------------"
done
......
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