diff options
Diffstat (limited to 'commit')
-rwxr-xr-x | commit | 145 |
1 files changed, 0 insertions, 145 deletions
@@ -1,145 +0,0 @@ -#!/bin/bash -# -# Commit both on git and svn -# - -# Parameters -ARGS="$*" - -# Check if a file is inside a git repository -# Usage: git_folder <file> -function git_folder { - - local folder="$1" folder folders dir_list cwd - - if [ -d "$folder/.git" ]; then - GIT_FOLDER="$folder" - return - fi - - # reverse folder order - dir_list="`echo $folder | tr '/' ' '`" - for i in $dir_list; do - folders="$i $folders" - done - - cwd="`pwd`" - cd $folder - - for i in $folders; do - cd .. - if [ -d "$(pwd)/.git" ]; then - GIT_FOLDER="$(pwd)" - cd $cwd - return - fi - done - - cd $cwd - return 1 - -} - -# Check if a folder is inside a git repository -function is_git { - # simple git folder checker - # usage: is_git <folder> - if [ -z "$1" ]; then - return 1 - elif [ ! -d "$1" ]; then - return 1 - elif [ -d "$1/.git" ]; then - return - else - ( cd "$1" && git status &> /dev/null ) - - if [ "$?" != "128" ]; then - return - else - return 1 - fi - fi -} - -# Check if a folder is inside a svn repository -function is_svn { - # simple svn folder checker - # usage: is_svn <folder> - - if [ -d "$1/.svn" ]; then - return - else - return 1 - fi -} - -# Push to repositories -function git_push { - if [ "`git remote | wc -l`" == "0" ]; then - return - elif git remote | grep -q 'all'; then - git push all --all - elif git remote | grep -q 'origin'; then - echo "Please configure the 'all' remote first." - exit 1 - #git push --all - fi -} - -# Check user information -function git_user { - if [ -z "`git config --local user.email`" ] || [ -z "`git config --local user.name`" ]; then - if echo $ARGS | grep -q -- '--config'; then - if grep -q "^\[user\]" $HOME/.gitconfig; then - grep -A 2 "^\[user\]" $HOME/.gitconfig >> $GIT_FOLDER/.git/config - else - grep -A 2 "^\[user\]" $HOME/.custom/gitconfig >> $GIT_FOLDER/.git/config - fi - else - - echo "No user configuration section found in the repository." - echo "This might be a privacy issue" - echo "" - - if [ -e "$HOME/.custom/gitconfig" ]; then - echo "You should try to use your default setting:" - echo "" - - if [ "$GIT_FOLDER" == "$(pwd)" ]; then - echo "cat <<EOF >> .git/config" - else - echo "cat <<EOF >> $GIT_FOLDER/.git/config" - fi - grep -A 2 "^\[user\]" $HOME/.custom/gitconfig - echo "EOF" - - echo "" - echo "Use --config if you want these lines to be added at .git/config" - fi - - exit 1 - - fi - fi -} - -# Commit changes -function git_commit { - # Remove '--config' from args, otherwise it goes to the commit log - params="`echo $* | sed -e 's/--config//'`" - git commit -a -m "$params" -} - -# Main -if [ ! -z "$1" ]; then - if is_svn .; then - svn commit -m "$*" - fi - - if is_git .; then - git_folder $(pwd) - git_user - git_commit $* - git_push - fi -fi |