#!/bin/bash
#########################################################
# 							#
# This is BashStyle-NG  				#
#							#
# Licensed under GNU GENERAL PUBLIC LICENSE v3    	#
#							#
# Copyright 2007 - 2011 Christopher Bratusek		#
#							#
#########################################################

wizard_git_base ()
{

whiptail --title $"GIT setup" --yesno $"Do you want to configure GIT?" 12 85

export USER_WANTS_GIT=$?

	if [[ $USER_WANTS_GIT == "0" ]]; then

		gituser=$(whiptail --title $"GIT username" --inputbox $"Enter your real name to be used by GIT:" 12 85 "$(wizard_get git_user_name)" 3>&1 1>&2 2>&3)
		if [[ $gituser != "" ]]; then
			wizard_set git_user_name $gituser
		fi

		gitmail=$(whiptail --title $"GIT email" --inputbox $"Enter your email to be used by GIT:" 12 85 "$(wizard_get git_user_mail)" 3>&1 1>&2 2>&3)
		if [[ $gitmail != "" ]]; then
			wizard_set git_user_mail $gitmail
		fi

		whiptail --title $"GIT key" --yesno $"Do you want to set a default key for signing off GIT?" 12 85

		if [[ $? == "0" ]]; then
			gitkey=$(whiptail --title $"default git signing key" --inputbox $"Enter the default key for signing off GIT:" 12 85 "$(wizard_get git_signkey)" 3>&1 1>&2 2>&3)
			if [[ $gitkey != "" ]]; then
				wizard_set git_signkey $gitkey
			fi
		fi


		whiptail --title $"GIT color" --yesno $"Do you want colored output from GIT?" 12 85

		if [[ $? == "0" ]]; then
			wizard_set git_color True
		else	wizard_set git_color False
		fi

		giteditor=$(whiptail --title $"Editor for GIT" --inputbox $"What editor to use for GIT commit messages & Co?:" 12 85 "$(wizard_get git_editor)" 3>&1 1>&2 2>&3)
		if [[ $giteditor != "" ]]; then
			wizard_set git_editor $giteditor
		fi

		whiptail --title $"SVN compat" --yesno $"Do you want some aliases to be defined?
git co [git checkout]
git up [git pull]
git re [git reset --hard HEAD]
git ma [git checkout master]
git who [git shortlog -s --]" 12 85

		if [[ $? == "0" ]]; then
			wizard_set git_aliases True
		else 	wizard_set git_aliases False
		fi

	fi

}

wizard_git_accounts ()
{
	if [[ $USER_WANTS_GIT == "0" ]]; then
		whiptail --title $"git.gnome.org" --yesno $"Do you have a GNOME GIT account?
With this info get_gnome can clone GIT repos with write access." 12 85

		if [[ $? == "0" ]]; then
			get_gnome_user=$(whiptail --title $"git.gnome.org account" --inputbox $"What's your GNOME GIT Account?:" 12 85 "$(wizard_get gnome_vcs_user)" 3>&1 1>&2 2>&3)
			wizard_set gnome_vcs_user $get_gnome_user
		fi

		whiptail --title $"git.xfce.org" --yesno $"Do you have a XFCE GIT account?
With this info get_xfce can clone GIT repos with write access." 12 85

		if [[ $? == "0" ]]; then
			get_xfce_user=$(whiptail --title $"git.xfce.org account" --inputbox $"What's your XFCE GIT Account?:" 12 85 "$(wizard_get xfce_vcs_user)" 3>&1 1>&2 2>&3)
			wizard_set xfce_vcs_user $get_xfce_user
		fi

		whiptail --title $"git.kde.org" --yesno $"Do you have a KDE GIT account?
With this info get_kde can checkout GIT repos with write access." 12 85

		if [[ $? == "0" ]]; then
			get_kde_user=$(whiptail --title $"git.kde.org account" --inputbox $"What's your KDE GIT Account?:" 12 85 "$(wizard_get kde_vcs_user)" 3>&1 1>&2 2>&3)
			wizard_set kde_vcs_user $get_kde_user
		fi

	fi

	unset USER_WANTS_GIT
}
