From 565837f28afe629e1044ccd079182dc07d94be37 Mon Sep 17 00:00:00 2001 From: Bobby Date: Sat, 5 Nov 2022 00:01:23 -0400 Subject: Created a file committer --- commit.sh | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 12 ++++++++ 2 files changed, 96 insertions(+) create mode 100755 commit.sh create mode 100644 requirements.txt diff --git a/commit.sh b/commit.sh new file mode 100755 index 0000000..878714a --- /dev/null +++ b/commit.sh @@ -0,0 +1,84 @@ +# This script is used to process certain files or run certain commands +# before a commit is made. You should use this script instead of +# using the any of the git commands directly. + +# This script is called with the following arguments: +# $1 - files to be committed (space separated) or '.' if all files +# $2 - commit message preceded by a '-m' +# $3 - change type (optional) - valid values are 'feat', 'fix', +# 'docs', 'style', 'refactor', 'perf', 'test', 'chore' or +# 'revert'. If not specified, 'feat' is assumed. Must be +# specified preceded by a '-t' flag. +# $4 - branch name (optional) - if not specified, the current branch +# is assumed. Must be specified preceded by a '-b' flag. + +# This script should return 0 if the commit should proceed or 1 if +# the commit should be aborted. + +# Get the current branch name +branch=$(git rev-parse --abbrev-ref HEAD) + +# Get arguments passed to this script +files=$1 +message=$2 +type=$3 +branch=$4 + +# Check if the branch name is specified +if [ "$branch" != "" ]; then + # Check if the branch name is valid + if [ $(git branch | grep -c "$branch") -eq 0 ]; then + echo "Branch $branch does not exist" + exit 1 + fi +fi + +# Check if the change type is specified +if [ "$type" != "" ]; then + # Check if the change type is valid + if [ $(echo $type | grep -c "feat\|fix\|docs\|style\|refactor\|perf\|test\|chore\|revert") -eq 0 ]; then + echo "Invalid change type $type" + exit 1 + fi +fi + +# Check if the commit message is specified, if not, prompt the user +if [ "$message" = "" ]; then + echo "Enter commit message (required):" + read message +fi + + +# Check if files are specified, if not, prompt the user +if [ "$files" = "" ]; then + echo "Enter files to be committed (space separated) or '.' for all files (required):" + read files +fi + + +# Generate requirements.txt file, delete it if it already exists +if [ -f requirements.txt ]; then + rm requirements.txt +fi +pip3 freeze > requirements.txt + + +# Add files to be committed +git add $files +git add requirements.txt + +# Modify the message in the following format: : +if [ "$type" != "" ]; then + message="$type: $message" +fi + +# Commit the changes +git commit -m "$message" + +# Push the changes to the remote branch +if [ "$branch" != "" ]; then + git push origin $branch +else + git push origin $branch +fi + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7ee0492 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,12 @@ +cfgv==3.3.1 +distlib==0.3.6 +filelock==3.8.0 +identify==2.5.8 +nodeenv==1.7.0 +platformdirs==2.5.2 +pre-commit==2.20.0 +pyspark==3.2.0 +PyYAML==6.0 +tk==0.1.0 +toml==0.10.2 +virtualenv==20.16.6 -- cgit v1.2.3