sliit-foss / gists

MIT License
3 stars 2 forks source link

Git commit from user pool #10

Closed Akalanka47000 closed 2 months ago

Akalanka47000 commented 2 months ago

Could someone please help migrate this over to the instructed markdown format which this repository follows

Description:

 Makes things a little bit faster if you were to commit as multiple users to a single repository

Usage:

 - sh cfup "chore: some commit message" - Commits and pushes as a random user from the pool

 - sh cfup "chore: some commit message" shelob - Commits and pushes as user shelob

Script:

#!/bin/bash

message=$1
user=$2

configure_commit_push() {
   git config user.name "$1"
   git config user.email "$2"
   git add . && git commit -m "$message" && git push
}

talion() {
    configure_commit_push "Talion" "talion@gmail.com"
}

celebrimbor() {
    configure_commit_push "Celebrimbor" "celebrimbor@gmail.com"
}

shelob() {
    configure_commit_push "Shelob" "shelob@gmail.com>"
}

functions=("talion" "celebrimbor" "shelob")

if [ -z "$user" ]; then
    random_function=${functions[$RANDOM % ${#functions[@]}]}
    $random_function
elif type "$user" >/dev/null 2>&1; then
    $user
else
    echo "Invalid user provided."
fi