mirror of
https://github.com/Snigdha-OS/snigdhaos-pkgbuilds.git
synced 2025-09-21 20:14:59 +02:00
🧪 test(_config): add github config option
This commit is contained in:
76
config.sh
76
config.sh
@@ -1,47 +1,53 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Author : ESHAN ROY
|
# Author: Eshan Roy <eshan@snigdhaos.org>
|
||||||
# Author URI : https://eshanized.github.io
|
# Author URI : https://eshanized.github.io
|
||||||
|
|
||||||
# NOTE : Run at your own Risk!
|
set -e
|
||||||
|
|
||||||
# Function to print GitHub credential configuration options
|
usage() {
|
||||||
print_options() {
|
echo "Usage: ${0##*/} [--email <email>] [--username <username>] [-h]"
|
||||||
echo "🔒 Configure GitHub Credentials:"
|
echo " --email <email> Set the GitHub user email"
|
||||||
echo "1. 📝 Enter GitHub username and password"
|
echo " --username <email> Set the GitHub username"
|
||||||
echo "2. 🔑 Enter GitHub personal access token"
|
echo " -h Display the help message"
|
||||||
echo "3. 📁 Use existing GitHub credentials from ~/.gitconfig"
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print options and prompt user to select
|
while [[ "$#" -gt 0 ]]; do
|
||||||
print_options
|
case "$1" in
|
||||||
echo "Enter the number of your chosen option:"
|
--email)
|
||||||
read -r OPTION
|
EMAIL="$2"
|
||||||
|
shift 2
|
||||||
# Handle user selection
|
|
||||||
case $OPTION in
|
|
||||||
1)
|
|
||||||
echo "Enter your GitHub username:"
|
|
||||||
read -r USERNAME
|
|
||||||
echo "Enter your GitHub password:"
|
|
||||||
read -s PASSWORD
|
|
||||||
git config --global credential.helper store
|
|
||||||
git config --global credential.username $USERNAME
|
|
||||||
git config --global credential.password $PASSWORD
|
|
||||||
;;
|
;;
|
||||||
2)
|
--username)
|
||||||
echo "Enter your GitHub personal access token:"
|
USERNAME="$2"
|
||||||
read -r TOKEN
|
shift 2
|
||||||
git config --global credential.helper store
|
|
||||||
git config --global credential.username "your-github-username"
|
|
||||||
git config --global credential.password $TOKEN
|
|
||||||
;;
|
;;
|
||||||
3)
|
-h|--help)
|
||||||
echo "Using existing GitHub credentials from ~/.gitconfig"
|
usage
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Invalid option. Exiting."
|
echo "Unknown argument found: $1"
|
||||||
exit 1;;
|
usage
|
||||||
esac
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
echo "GitHub credentials configured successfully! 👍"
|
# We will ask prompt for email address if not entered by the user
|
||||||
|
if [ -z "$EMAIL" ]; then
|
||||||
|
read -p "Enter your GitHub Email: " EMAIL
|
||||||
|
fi
|
||||||
|
|
||||||
|
# We will ask prompt for username if not entered by the user
|
||||||
|
if [ -z "$USERNAME" ]; then
|
||||||
|
read -p "Enter your GitHub Username: " USERNAME
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Setting up github config
|
||||||
|
git config --global user.email "$EMAIL"
|
||||||
|
git config --global user.name "$USERNAME"
|
||||||
|
|
||||||
|
# Get a confirmation message on successful update!
|
||||||
|
echo "GitHub Configuration setup successfull!"
|
||||||
|
echo " User Email: $EMAIL"
|
||||||
|
echo " Username: $USERNAME"
|
0
snigdhaos-blackbox/PKGBUILD
Normal file
0
snigdhaos-blackbox/PKGBUILD
Normal file
Reference in New Issue
Block a user