Skip to content

Instantly share code, notes, and snippets.

@lorenzop
Created April 21, 2017 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lorenzop/18acec41383c33e79b4a0693e49b5c17 to your computer and use it in GitHub Desktop.
Save lorenzop/18acec41383c33e79b4a0693e49b5c17 to your computer and use it in GitHub Desktop.
#!/bin/bash
clear
source /usr/bin/shellscripts/common.sh
if [ $USER == "root" ]; then
echo "You cannot run this script as root!"
exit 1
fi
# create .gitconfig file
if [ ! -f ~/.gitconfig ]; then
# ask username
echo
echo "What is your github username?"
answer=""
read answer
username="$answer"
# ask email
echo
echo "What is your github email address?"
answer=""
read answer
email="$answer"
# write file
echo "[core]" > ~/.gitconfig
echo -e "\tautocrlf = input" >> ~/.gitconfig
echo "[user]" >> ~/.gitconfig
echo -e "\tname = ${username}" >> ~/.gitconfig
echo -e "\temail = ${email}" >> ~/.gitconfig
echo
fi
tempfile="/tmp/pxn-clone-script-menu"
rm -f --preserve-root "$tempfile"
dialog --backtitle "Project Group" \
--menu "Select a project group to configure" \
15 40 8 \
1 "gc" \
2>"$tempfile"
answer=`cat "$tempfile"`
case "$answer" in
1)
answer="gc"
;;
*)
echo
echo
echo
exit 1
;;
esac
function git_clone() {
dir="$1"
repo="$2"
if [ -e "$dir/" ]; then
title "Pushing/Pulling Repo: $repo"
pushd "${dir}/" || exit 1
# tee this to grep out the 14 local objects pushed/pulled
#Counting objects: 117, done.
#Delta compression using up to 4 threads.
#Compressing objects: 100% (87/87), done.
#Writing objects: 100% (117/117), 26.44 KiB | 0 bytes/s, done.
#Total 117 (delta 55), reused 0 (delta 0)
#remote: Resolving deltas: 100% (55/55), completed with 14 local objects.
#To github.com:GrowControl/pxnCommon.git
# 202e4f6..a83633f master -> master
git push || exit 1
echo
git pull || exit 1
popd
else
title "Cloning Repo: $repo"
git clone git@github.com:"$repo" || exit 1
fi
# create/update .gitignore file
cat >"${dir}/.gitignore" <<EOF
.git/
debug
DEBUG
.debug
error_log
pxnloader.php
.htdb*
config.php
public/static/bootstrap
public/static/jquery
.cache/
.*_cache/
.backups/
*.lock
bin/
target/
vendor/
coverage/
rpmbuild-root/
out/
build/
composer.phar
auth.json
.classpath
.project
.buildpath
.gradle/
.settings/
*.class
*.iml
*.idea
*.jar
*.rpm
*.deb
*.apk
*.war
*.ear
*.zip
*.exe
*.out
*.swp
.*.swp
*~
EOF
# create/update .gitattributes file
cat >"${dir}/.gitattributes" <<EOF
# https://help.github.com/articles/dealing-with-line-endings/
* text eol=lf
.gitignore text
.gitattributes text
README text
build.gradle text
settings.gradle text
*.properties text
*.md text
*.txt text
*.php text
*.pl text
*.conf text
*.config text
*.sample text
*.example text
*.spec text
*.htm text
*.html text
*.xhtml text
*.xml text
*.js text
*.css text
*.json text
*.yml text
*.yaml text
*.svg text
*.sh text
*.bat text
*.png binary
*.jpg binary
*.gif binary
*.ico binary
*.pdf binary
*.jar binary
*.zip binary
*.gz binary
*.tar binary
*.bin binary
*.rpm binary
*.exe binary
*.dll binary
*.class binary
*.so binary
*.o binary
*.obj binary
*.map binary
EOF
echo
}
clear
echo
case "$answer" in
# gc group
"gc")
git_clone "pxnCommon" "GrowControl/pxnCommon.git"
git_clone "GrowControl" "GrowControl/GrowControl.git"
# git_clone "gcLab" "GrowControl/gcLab.git"
# git_clone "gcStudio" "GrowControl/gcStudio.git"
# git_clone "ExamplePlugin" "GrowControl/ExamplePlugin.git"
# git_clone "gcTimer" "GrowControl/gcTimer.git"
# git_clone "ArduinoGC" "GrowControl/ArduinoGC.git"
# git_clone "gcSequencer" "GrowControl/gcSequencer.git"
# git_clone "gcgpio" "GrowControl/gcgpio.git"
# git_clone "gcButton" "GrowControl/gcButton.git"
title "Finished!"
exit 0
;;
# gc group done
*)
title "Unknown State!"
exit 1
esac
echo
echo
ls -lAsh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment