pax_global_header00006660000000000000000000000064123032263310014505gustar00rootroot0000000000000052 comment=4a763fc751bede7dd08c127645f1396e4e8626b9 giter-0.3/000075500000000000000000000000001230322633100124575ustar00rootroot00000000000000giter-0.3/.gear/000075500000000000000000000000001230322633100134535ustar00rootroot00000000000000giter-0.3/.gear/rules000064400000000000000000000000071230322633100145250ustar00rootroot00000000000000tar: . giter-0.3/.gitignore000064400000000000000000000000031230322633100144400ustar00rootroot00000000000000*~ giter-0.3/AUTHORS000064400000000000000000000001061230322633100135240ustar00rootroot00000000000000Vitaly Lipatov Denis Smirnov giter-0.3/Makefile000064400000000000000000000001221230322633100141120ustar00rootroot00000000000000install: mkdir -p $(DESTDIR)$(bindir) install -m 755 bin/* $(DESTDIR)$(bindir) giter-0.3/README.md000064400000000000000000000061561230322633100137460ustar00rootroot00000000000000 giter — набор команд, упрощающих повседневную работу с репозиторием. Отличительной особенностью всех команд является то, что их можно и нужно использовать без параметров, они будут стараться выполнить то, что вам нужно. Все эти команды при выполнении выводят то, что они на самом деле запускают для выполнения действия. Не забывайте использовать справку: $ команда --help = Работа с удалённым репозиторием = $ gremote — посмотреть список удалённых репозиториев (аналог git remote -v) $ gpush — опубликовать изменения на удалённом репозитории У gpush есть отдельное поведение для удалённых репозиториев, псевдонимы которых начинаются с «git.», например, git.alt, git.github и т.п. Если таких репозиториев несколько, публикация будет происходить во все репозитории. $ gpull — получить изменения из удалённого репозитория Важно то, что gpull по умолчанию вызывает git pull --ff-only, то есть не даёт создаваться мержам. Если наткнулись на ситуацию, когда обновление не происходит, потому что у вас тоже есть новый коммит, используйте gpull -r (git pull --rebase). = Работа с репозиторием = $ gamend [файл] — выполнить git amend [файл] без вопросов о редактировании комментария $ grebase — чуть более понятый запуск git rebase -i HEAD^N, который задаёт вопрос о коммите, с которого делать rebase. = Примеры использования = 1. Если вы вносите исправления, которые должны добавиться к последнему уже сделанному коммиту, просто запустите gamend (возможно, указав файл) после изменений файла. 2. Если вам нужно публиковать ваш репозиторий сразу в несколько удалённых, сделайте псевдонимы к ним начинающимися с git. 3. Всегда используйте gpull при получении изменений из удалённого репозитория. Это позволит избежать ненужных merge. = Прочее = $ ginit — создать удалённый репозиторий (работает только при использовании girar) git config --local merge.ff only giter-0.3/bin/000075500000000000000000000000001230322633100132275ustar00rootroot00000000000000giter-0.3/bin/gamend000075500000000000000000000025131230322633100144110ustar00rootroot00000000000000#!/bin/sh # # Copyright (C) 2012-2014 Etersoft # Copyright (C) 2012-2014 Vitaly Lipatov # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # PROGDIR=$(dirname $0) [ "$PROGDIR" = "." ] && PROGDIR=$(pwd) . $PROGDIR/giter-common-functions # Do commit --amend for all files in the repo if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then echo "gamend - do fast git commit amend (apply all current changes to the last commit)" echo "Use: gamend [-e] [file]" echo " -e - edit commit message" exit fi #AMENDARG=" --date=\"$(date -R)\" -C HEAD" AMENDARG=" --reset-author -C HEAD" if [ "$1" = "-e" ] ; then AMENDARG= shift fi # If no args if [ -z "$1" ] ; then AMENDARG="$AMENDARG -a" fi docmd git commit --amend $AMENDARG $@ giter-0.3/bin/ginit000075500000000000000000000031331230322633100142670ustar00rootroot00000000000000#!/bin/sh # # Copyright (C) 2008-2014 Etersoft # Copyright (C) 2008-2014 Vitaly Lipatov # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # PROGDIR=$(dirname $0) [ "$PROGDIR" = "." ] && PROGDIR=$(pwd) . $PROGDIR/giter-common-functions . $PROGDIR/giter-git-functions if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then echo "ginit - initialize repo in $GIRARHOST for current project" echo "Use: ginit [GIRAR]" echo " ginit git.eter - for create repo in the git.eter" exit 0 fi set_girar_host $1 && shift test -r "$1" && fatal "Do not need any params more" RPNAME=$(get_gear_name) # FIXME: если не нашли, стоит взять название каталога за основу [ -n "$RPNAME" ] || fatal "Can't detect project name. Run inside git repo." # ALT Linux only echo "Create remote $RPNAME repo in $GIRARHOST:" docmd ssh $GIRARHOST git-init-db "$RPNAME.git" echo echo "Create $GIRARHOST remote repo alias:" docmd git remote add $GIRARHOST $GIRARHOST:packages/$RPNAME.git giter-0.3/bin/giter-common-functions000064400000000000000000000052601230322633100175630ustar00rootroot00000000000000#!/bin/sh # # Copyright (C) 2014 Etersoft # Copyright (C) 2014 Vitaly Lipatov # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # . $PROGDIR/giter-sh-functions estrlist() { $PROGDIR/giter-estrlist "$@" } # Args: LIST1 LIST2 # do_exclude_list print LIST2 exclude fields contains also in LIST1 # Example: do_exclude_list "1 3" "1 2 3 4" -> "2 4" do_exclude_list() { estrlist exclude "$@" } # TODO: move to git (in etersoft-build-utils too) # TODO: move to separate command get_root_git_dir() { local DIR=$(git rev-parse --git-dir 2>/dev/null)/../ || return readlink -f "$DIR" 2>/dev/null || realpath "$DIR" # FIXME: 1) can return / with good status 2) no one check status later } # TODO: move to separate gear file # TODO: rewrite with get_gear_rules_by_spec in mind get_gear_rules() { local DIR="$1" [ -z "$IGNOREGEAR" ] || return 1 [ -f "$DIR" ] && DIR=$(dirname "$DIR") [ -n "$DIR" ] && cd $DIR local GITDIR=$(get_root_git_dir) [ -n "$DIR" ] && cd - >/dev/null local rules="$GITDIR/.gear/rules" [ -r "$rules" ] || rules="$GITDIR/.gear-rules" [ -r "$rules" ] || return echo $rules } # Usage: is_gear [path_to_spec|dir_inside_git] is_gear() { get_gear_rules $@ >/dev/null } filter_gear_name() { sed -e "s|\+|plus|g" } # FIXME: use in rpmbs, fix for package name from spec get_gear_name() { local gitdir=$(get_root_git_dir) [ -n "$gitdir" ] || return basename "$gitdir" | filter_gear_name } get_girar_host_from_ssh() { grep -i "host[\t ]\+" ~/.ssh/config | sed "s|.*host[\t ]*||gi" | grep "^git\." | head -n1 } # load user config file if [ -f ~/.config/giter ] ; then . ~/.config/giter fi # TODO: merge with sh-functions echocon() { tty -s && echo "$@" } initial_letter() { echo "$1" | head -n1 | cut -c1 } # copied from repos get_git_url() { # HACK test -r /etc/eterbuild/repos/gitalias || fatal "Please install etersoft-build-utils package for use" grep "^$1 " /etc/eterbuild/repos/gitalias | cut -f2 -d" " } assert_var() { local i re for i in $@ ; do re=$(eval echo \$$i) [ -n "$re" ] || fatal "assert: $i nonexist" done } giter-0.3/bin/giter-estrlist000075500000000000000000000123301230322633100161350ustar00rootroot00000000000000#!/bin/bash # 2009-2010, 2012 Etersoft www.etersoft.ru # Author: Vitaly Lipatov # Public domain # TODO: rewrite with shell commands, perl or C # Python - http://www.linuxtopia.org/online_books/programming_books/python_programming/python_ch16s03.html # Shell - http://linux.byexamples.com/archives/127/uniq-and-basic-set-theory/ # - http://maiaco.com/articles/shellSetOperations.php # Perl - http://docstore.mik.ua/orelly/perl/cookbook/ch04_09.htm # - http://blogs.perl.org/users/polettix/2012/03/sets-operations.html # http://rosettacode.org/wiki/Symmetric_difference # TODO: add unit tests # http://ru.wikipedia.org/wiki/Операции_над_множествами # Base set operations: # * union # "1 2 3" "3 4 5" -> "1 2 3 4 5" # * intersection # "1 2 3" "3 4 5" -> "3" # * relative complement (substracted, difference) ( A ? B – members in A but not in B ) # http://en.wikipedia.org/wiki/Complement_%28set_theory%29 # "1 3" "1 2 3 4" -> "2 4" # * symmetric difference (симметричная разность) ( A ^ B – members in A or B but not both ) # http://en.wikipedia.org/wiki/Symmetric_difference # "1 2 3" "3 4 5" -> "1 2 4 5" filter_strip_spaces() { # possible use just #xargs echo sed -e "s| \+| |g" -e "s|^ ||" -e "s| \$||" } strip_spaces() { echo "$*" | filter_strip_spaces } list() { local i for i in $@ ; do echo "$i" done } count() { list $@ | wc -l } union() { strip_spaces $(list $@ | sort -u) } uniq() { union $@ } has() { local wd="$1" shift echo "$@" | grep -q "$wd" } # remove_from_list "1." "11 12 21 22" -> "21 22" reg_remove() { local i local RES= for i in $2 ; do echo "$i" | grep -q "$1" || RES="$RES $i" done strip_spaces "$RES" } # remove_from_list "1." "11 12 21 22" -> "21 22" reg_wordremove() { local i local RES= for i in $2 ; do echo "$i" | grep -q -w "$1" || RES="$RES $i" done strip_spaces "$RES" } # Args: LIST1 LIST2 # do_exclude_list print LIST2 list exclude fields contains also in LIST1 # Example: exclude "1 3" "1 2 3 4" -> "2 4" exclude() { local i local RES= for i in $2 ; do echo "$1" | grep -q -w "$i" || RES="$RES $i" done strip_spaces "$RES" } # regexclude_list "22 1." "11 12 21 22" -> "21" reg_exclude() { local i local RES="$2" for i in $1 ; do RES=$(reg_remove "$i" "$RES") done strip_spaces "$RES" } # regexclude_list "22 1." "11 12 21 22" -> "21" reg_wordexclude() { local i local RES="$2" for i in $1 ; do RES=$(reg_wordremove "$i" "$RES") done strip_spaces "$RES" } # FIXME: # reg_include "1." "11 12 21 22" -> "11 12" reg_include() { local i local RES= for i in $2 ; do echo "$i" | grep -q -w "$1" && RES="$RES $i" done strip_spaces "$RES" } example() { local CMD="$1" local ARG1="$2" shift 2 echo "\$ $0 $CMD \"$ARG1\" \"$@\"" $0 $CMD "$ARG1" "$@" } example_res() { example "$@" && echo TRUE || echo FALSE } help() { echo "estrlist developed for string list operations. See also cut, join, paste..." echo "Usage: $0 [args]" echo "Commands:" echo "strip_spaces [args] - remove spaces between words" echo "filter_strip_spaces - remove spaces from words from standart input" echo "reg_remove [word list] - remove words containing a match to the given PATTERN (grep notation)" echo "reg_wordremove [word list] - remove words containing a match to the given PATTERN (grep -w notation)" echo "exclude [list2] - print list2 words contains also in list1" echo "reg_exclude [word list] - print only words not matched with PATTERN" echo "reg_wordexclude [word list] - print only words not matched with PATTERN" echo "union [word list] - sort and remove duplicates" echo "uniq [word list] - alias for union" echo "list [word list] - just list words line by line" echo "count [word list] - print word count" echo echo "Examples:" example reg_remove "1." "11 12 21 22" example reg_wordremove "1." "11 12 21 22" example exclude "1 3" "1 2 3 4" example reg_exclude "22 1." "11 12 21 22" example reg_wordexclude "wo.* er" "work were more else" example union "1 2 2 3 3" example count "1 2 3 4 10" example_res has ex "exactly" example_res has exo "exactly" } COMMAND="$1" if [ -z "$COMMAND" ] ; then echo "Run with --help for get command description." exit 1 fi if [ "$COMMAND" = "-h" ] || [ "$COMMAND" = "--help" ] ; then COMMAND="help" fi shift # FIXME: do to call function directly, use case instead? if [ "$1" = "-" ] ; then shift "$COMMAND" "$(cat) $@" elif [ "$2" = "-" ] ; then "$COMMAND" "$1" "$(cat)" else "$COMMAND" "$@" fi giter-0.3/bin/giter-girar-functions000064400000000000000000000033021230322633100173720ustar00rootroot00000000000000#!/bin/bash # # Copyright (C) 2013-2014 Etersoft # Copyright (C) 2013-2014 Vitaly Lipatov # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # # copied from etersoft-build-utils/share/eterbuild/functions/girar # Is allow connect with ssh to the GIRARHOST server? has_ssh_girar_access() { ssh $GIRARHOST help >/dev/null 2>&1 } check_http_status() { a= curl -s -I "$1" | grep HTTP | grep -q "200 OK" } # Returns true if repo with path from first arg is exits on the remote GIRARHOST server is_exist_git_repo() { if has_ssh_girar_access ; then ssh $GIRARHOST ls $1 >/dev/null 2>&1 && return fi # TODO: this is workaround for ALT bug #22745 # https://bugzilla.altlinux.org/show_bug.cgi?id=22745 check_http_status $(get_git_url $GIRARHOST)$1 } # get gear repo for package name get_girar_repo() { assert_var GIRARHOST local PKGNAME="$1" # http://git.altlinux.org/gears/N/NAME.git local REPOPATH="$(initial_letter $PKGNAME)/$PKGNAME.git" local RREPO="/gears/$REPOPATH" if ! is_exist_git_repo $RREPO ; then RREPO="/srpms/$REPOPATH" is_exist_git_repo $RREPO || return fi echo "$RREPO" } giter-0.3/bin/giter-git-functions000064400000000000000000000062121230322633100170540ustar00rootroot00000000000000#!/bin/bash # # Copyright (C) 2008-2014 Etersoft # Copyright (C) 2008-2014 Vitaly Lipatov # Copyright (C) 2008 Denis Smirnov # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # # copied from etersoft-build-utils/share/eterbuild/functions/git get_branch_list() { git branch | grep '^ ' | sed 's/^..\(.*\)/\1/' } get_remote_repo_list() { git remote "$@" 2>/dev/null | sort -u } is_exist_branch() { test -n "$1" || return 1 get_branch_list | grep -q $1 } is_exist_remote_repo() { test -n "$1" || return 1 get_remote_repo_list | grep -q $1 } get_current_branch() { git branch | grep '^\*' | sed 's/^..//' | tr -d "\n" } get_remote_git_list() { local i for i in $(get_remote_repo_list) ; do if is_girar_name $i ; then echo $i fi done } # Check if $1 like git.alt or git.eter, git.something is_girar_name() { echo "$1" | grep -q "^git\." } is_one_girar_name() { local i local RES="" for i in $@ ; do [ -z "$RES" ] || return is_girar_name "$i" || return RES="$i" done [ -n "$RES" ] } # Try autodetect GIRARHOST. Return true, if get it from arg (need for shift args) set_girar_host() { if is_girar_name "$1" ; then GIRARHOST="$1" return 0 fi # Try get from remote list, if unique record there REMOTELIST="$(get_remote_git_list)" if is_one_girar_name "$REMOTELIST" ; then # use one target if it one GIRARHOST="$REMOTELIST" return 1 fi # if no default, set default GIRARHOST from ~/.ssh/config if [ -z "$GIRARHOST" ] ; then GIRARHOST=$(get_girar_host_from_ssh) #[ -n "$GIRARHOST" ] || fatal "Can't get default girar alias (like git.alt) from ~/.ssh/config" fi return 1 } _list_git_package() { while read path date other; do printf "%60s " $GIRARHOST:$path [ -n "$date" ] || { echo "[Date is missed]" ; continue ; } date -d@$date done } # TODO: make world better, please list_git_package() { ssh $GIRARHOST find-package $1 | _list_git_package } git_commit_ignore_nothing() { git commit "$@" && return git commit "$@" 2>&1 | grep "nothing to commit" && return 0 return 1 } get_last_tag() { git describe --abbrev=0 --tags 2>/dev/null } # check if tag is last commit tag (put on the last commit). if tag is missed, check with the last tag in repo is_last_commit_tag() { local TAG=$1 test -n "$TAG" || TAG=$(get_last_tag) [ -n "$TAG" ] || return # check if the tag put on the last commit [ "$(git rev-parse HEAD)" = "$(git rev-parse $TAG^0)" ] } giter-0.3/bin/giter-sh-functions000064400000000000000000000065421230322633100167110ustar00rootroot00000000000000#!/bin/sh # # Copyright (C) 2012 Etersoft # Copyright (C) 2012 Vitaly Lipatov # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # # copied from eepm project # copied from /etc/init.d/outformat (ALT Linux) isatty() { # Set a sane TERM required for tput [ -n "$TERM" ] || TERM=dumb export TERM test -t 1 } check_tty() { isatty || return which tput >/dev/null 2>/dev/null || return # FreeBSD does not support tput -S echo | tput -S >/dev/null 2>/dev/null || return [ -z "$USETTY" ] || return export USETTY=1 } : ${BLACK:=0} ${RED:=1} ${GREEN:=2} ${YELLOW:=3} ${BLUE:=4} ${MAGENTA:=5} ${CYAN:=6} ${WHITE:=7} set_boldcolor() { [ "$USETTY" = "1" ] || return { echo bold echo setaf $1 } |tput -S } restore_color() { [ "$USETTY" = "1" ] || return { echo op; # set Original color Pair. echo sgr0; # turn off all special graphics mode (bold in our case). } |tput -S } echover() { [ -n "$verbose" ] || return echo "$*" >&2 } # Print command line and run command line showcmd() { if [ -z "$quiet" ] ; then set_boldcolor $GREEN local PROMTSIG="\$" [ "$UID" = 0 ] && PROMTSIG="#" echo " $PROMTSIG $@" restore_color fi >&2 } # Print command line and run command line docmd() { showcmd "$@" "$@" } # Run every arg with docmd docmd_foreach() { local cmd cmd="$1" #showcmd "$@" shift for pkg in "$@" ; do docmd $cmd $pkg done } # Print command line and run command line with SUDO sudocmd() { showcmd "$SUDO $@" $SUDO "$@" } # Run every arg with sudocmd sudocmd_foreach() { local cmd cmd="$1" #showcmd "$@" shift for pkg in "$@" ; do sudocmd $cmd $pkg done } filter_strip_spaces() { # possible use just #xargs echo sed -e "s| \+| |g" | \ sed -e "s|^ ||" | sed -e "s| \$||" } strip_spaces() { echo "$*" | filter_strip_spaces } # param true false subst_option() { eval "[ -n \"\$$1\" ]" && echo "$2" || echo "$3" } store_output() { # use make_temp_file from etersoft-build-utils RC_STDOUT=$(mktemp) #RC_STDERR=$(mktemp) "$@" 2>&1 | tee $RC_STDOUT # http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF return $PIPESTATUS } clean_store_output() { rm -f $RC_STDOUT } # Print error message and stop the program fatal() { if [ -z "$TEXTDOMAIN" ] ; then echo "Error: $@" >&2 # else # echog "Error in $0: $@" >&2 fi exit 1 } # Print warning message warning() { if [ -z "$TEXTDOMAIN" ] ; then echo "Warning: $@" >&2 # else # echog "Error in $0: $@" >&2 fi } # print options description from HELPCMD/HELPOPT lines in the code get_help() { grep -v -- "^#" $0 | grep -- "# $1" | while read n ; do opt=$(echo $n | sed -e "s|) # $1:.*||g") desc=$(echo $n | sed -e "s|.*) # $1:||g") printf " %-20s %s\n" $opt "$desc" done } giter-0.3/bin/gpull000075500000000000000000000073521230322633100143070ustar00rootroot00000000000000#!/bin/sh # # Copyright (C) 2009-2014 Etersoft # Copyright (C) 2009-2014 Vitaly Lipatov # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # PROGDIR=$(dirname $0) [ "$PROGDIR" = "." ] && PROGDIR=$(pwd) . $PROGDIR/giter-common-functions . $PROGDIR/giter-git-functions if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then echo "gpull - do git pull with fast forward only by default." echo echo "Usage: gpull [-a] [-n] [repo] [branch]" echo echo "gpull without parameters or with branch name" echo "gpull myrepo - for pull from remote myrepo gear repo (with --rebase by default)" echo echo "Options:" echo " -a pull all branches" echo " -r rebase during pull" echo " -m do merge if possible" echo " -f pull with fast forward only (default)" echo " -c return error status if repo was not uptodate (gpull || echo 'Was updated last time')" exit 0 fi REPO= if [ "$1" = "-a" ] ; then ALLBRANCHES=1 shift fi if [ "$1" = "-c" ] ; then CHECKRESULT=1 shift fi REBASE="--ff-only" if [ "$1" = "-r" ] ; then REBASE="--rebase" shift fi if [ "$1" = "-m" ] ; then REBASE="" shift fi if [ "$1" = "-f" ] ; then REBASE="--ff-only" shift fi if is_exist_remote_repo "$1" ; then REPO=$1 shift fi pull_all_branches() { local CURRENTBRANCH=$(get_current_branch) # pull all branches for i in $(get_branch_list) ; do docmd git checkout $i || fatal "can't checkout $i" docmd git pull --tags $REPO $i done docmd git checkout $CURRENTBRANCH } # Если не получилось получить обновление по такому же названию бранча, как локальный, то получаем по удалённому pull_from_unique_branch() { [ -n "$REPO" ] || return REMOTEBRANCH=$(git branch -a | grep "^ remotes/$REPO/" | sed -e "s|.*remotes/$REPO/||") if [ "$(estrlist count $REMOTEBRANCH)" -gt 1 ] ; then fatal "Can't detect remote branch in $(echo $REMOTEBRANCH). Run with one from these." fi docmd git pull $REBASE $REPO $REMOTEBRANCH } if [ -n "$ALLBRANCHES" ] ; then pull_all_branches exit fi REMOTEBRANCH="$1" # Only if set REPO if [ -n "$REPO" ] ; then # use current branch name as default [ -n "$REMOTEBRANCH" ] || REMOTEBRANCH=$(get_current_branch) fi if [ -n "$CHECKRESULT" ] ; then # Quiet in check mode #showcmd git pull --rebase $REPO $REMOTEBRANCH UPTODATEres=`git pull --rebase $REPO $REMOTEBRANCH 2>&1` # REWRITE ME: assure we get tags git pull --tags $REPO $REMOTEBRANCH echocon "$UPTODATEres" echo $UPTODATEres | tail -n1 | grep -q "is up to date" exit fi docmd git fetch $REPO || exit # FIXME: Не факт, что удалённо бранч называется именно $REMOTEBRANCH if ! LC_ALL=C store_output docmd git pull $REBASE $REPO $REMOTEBRANCH ; then if grep -q "fatal: Couldn't find remote ref" $RC_STDOUT ; then clean_store_output pull_from_unique_branch || exit else clean_store_output exit 1 fi fi clean_store_output # REWRITE ME: assure we get tags #docmd git pull --tags $REPO $REMOTEBRANCH docmd git fetch --tags $REPO $REMOTEBRANCH giter-0.3/bin/gpush000075500000000000000000000073101230322633100143040ustar00rootroot00000000000000#!/bin/sh # # Copyright (C) 2008-2014 Etersoft # Copyright (C) 2008-2014 Vitaly Lipatov # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # PROGDIR=$(dirname $0) [ "$PROGDIR" = "." ] && PROGDIR=$(pwd) . $PROGDIR/giter-common-functions . $PROGDIR/giter-git-functions test -r "$1" && fatal "Do not need any files in params" PUSHFORCE= PUSHALL= TAGSALL= NEWGIRAR= ############################# Usage="Usage: $name [GIRAR/remote alias] [-f|--force] [-a|--all] [-b|--branches] [-t|--tags] [tag]" mygetopts() { name=${0##*/} Descr="$name - publish to remote git repository" phelp() { echo "$Descr" echo "$Usage" echo "Options:" echo " -f - force push" echo " -a - push to all remotes" echo " -b - push all branches" echo " -t - push all tags" } while getopts :hfat opt; do case $opt in h) phelp; exit 0;; f) PUSHFORCE="--force" ;; a) PUSHTOALL="--toall" ;; b) PUSHALLBRANCHES="--allbranches" ;; t) TAGSALL="--tags" ;; +?) echo "$name: options should not be preceded by a '+'." 1>&2; exit 2;; ?) OPTIND=$((OPTIND-1)); break; esac done ## remove args that were options if [ $# -gt 0 ]; then shift $((OPTIND - 1)) fi LISTARGS="$@" #LISTARGS=$(drop_args "$*" f a t) } # TODO: rewrite NEWGIRAR defining # Skip first param if ! echo "$1" | grep -q "^-" ; then NEWGIRAR="$1" shift fi mygetopts $@ push_to_remote() { local GHOST=$1 local TEXTTAG= local PROJECTDIR=$(get_root_git_dir) [ -n "$TAGSALL" ] && TEXTTAG="(with all tags)" echo echo "** Push $TEXTBRANCH from $PROJECTDIR to $GHOST $TEXTTAG" docmd git push $PUSHALL $PUSHFORCE $GHOST $CURRENTBRANCH || return if [ -n "$TAGSALL" ] ; then docmd git push --tags $GHOST $CURRENTBRANCH else if is_last_commit_tag ; then local LASTTAG=$(get_last_tag) if [ -n "$LASTTAG" ] ; then echo "*** Push last tag $LASTTAG" docmd git push $PUSHFORCE $GHOST $LASTTAG fi fi fi } tune_girarlist() { REMOTELIST="$(get_remote_git_list)" set_girar_host if [ -z "$NEWGIRAR" ] ; then NEWGIRAR="$1" shift fi # If run with gear as param if [ -n "$NEWGIRAR" ] ; then # if run with girar host in arg if is_girar_name "$NEWGIRAR" ; then # if remote list is empty, do ginit [ -n "$REMOTELIST" ] || ginit $NEWGIRAR fi LISTGIRARHOST="$NEWGIRAR" else # use one target if it one if is_one_girar_name "$REMOTELIST" ; then GIRARHOST="$REMOTELIST" fi # origin by default if exists and alone if get_remote_repo_list | grep -q origin ; then GIRARHOST="origin" fi LISTGIRARHOST="$GIRARHOST $(do_exclude_list "$GIRARHOST" "$REMOTELIST")" fi if [ -n "$PUSHTOALL" ] ; then LISTGIRARHOST="$(get_remote_repo_list)" fi # if set it can be tag or branch name if [ -n "$1" ] ; then CURRENTBRANCH="$1" shift else CURRENTBRANCH=$(get_current_branch) fi [ -n "$CURRENTBRANCH" ] || fatal "Can't detect current branch" } tune_girarlist $LISTARGS if [ "$PUSHALLBRANCHES" = "--allbranches" ] ; then TEXTBRANCH="all branches" CURRENTBRANCH= else TEXTBRANCH="branch $CURRENTBRANCH" if git tag | grep -q "^$CURRENTBRANCH\$" ; then TEXTBRANCH="tag $CURRENTBRANCH" fi fi for i in $LISTGIRARHOST ; do push_to_remote $i done giter-0.3/bin/grebase000075500000000000000000000026101230322633100145640ustar00rootroot00000000000000#!/bin/sh # # Copyright (C) 2013-2014 Etersoft # Copyright (C) 2013-2014 Vitaly Lipatov # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # PROGDIR=$(dirname $0) [ "$PROGDIR" = "." ] && PROGDIR=$(pwd) . $PROGDIR/giter-common-functions # Do git rebase -i if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then echo "grebase - do interactive rebase for last N commits" echo "Use: grebase [N]" exit 0 fi NN=$1 if [ -z "$NN" ] ; then echo "Will do commit rebase. Last commit list:" git log --pretty=format:"%s, %cd" | head -n 20 | cat -n echo "Input line number (next after needed) or Enter to exit:" read NN other # try convert to numeric NN=$(($NN + 0)) [ "$NN" = "0" ] && fatal "Incorrect number" fi # TODO: select from commit list CID="HEAD~$NN" echo $CID docmd git rebase -i $CID giter-0.3/bin/gremote000075500000000000000000000041401230322633100146160ustar00rootroot00000000000000#!/bin/sh # # Copyright (C) 2012-2014 Etersoft # Copyright (C) 2012-2014 Vitaly Lipatov # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # PROGDIR=$(dirname $0) [ "$PROGDIR" = "." ] && PROGDIR=$(pwd) . $PROGDIR/giter-common-functions . $PROGDIR/giter-git-functions . $PROGDIR/giter-girar-functions if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then echo "gremote - git remote -v analogue" echo "Use: gremote" echo "Options:" echo " -u USER add path to USER package repo" echo " -o add path to the origin repo (/srpms or /gears)" exit 0 fi set_girar_host $1 && shift if [ "$1" = "-u" ] ; then shift RU="$1" [ -n "$RU" ] || fatal "User missed. Please, run as gremote -u USER" SPEC=$(get_gear_spec) build_rpms_name "$SPEC" # copied from rpmbs # FIXME: hack: get project name from package name PROJECTNAME=$(echo $BASENAME | filter_gear_name) [ -n "$PROJECTNAME" ] || fatal "Can't detect current project name" docmd git remote add $RU $GIRARHOST:/people/$RU/packages/$PROJECTNAME.git exit fi if [ "$1" = "-o" ] ; then # http://git.altlinux.org/gears/N/NAME.git PKGNAME=$(get_gear_name) echo "Get correct repo path for $PKGNAME from $GIRARHOST..." RREPO=$(get_girar_repo $PKGNAME) || fatal "Can't detect origin repo for $PKGNAME" # TODO: add http access support when have no ssh access docmd git remote add gear $GIRARHOST:$RREPO exit fi test -r "$1" && fatal "Do not need any params more" showcmd git remote -v git remote -v | sed -e "s|(fetch)$||" | sed -e "s|(push)$||" | sort -u giter-0.3/giter.spec000064400000000000000000000020201230322633100144370ustar00rootroot00000000000000Name: giter Version: 0.3 Release: alt1 Summary: Etersoft wrapper for git commands License: AGPLv3 Group: Development/Other Url: http://wiki.etersoft.ru/Giter Packager: Vitaly Lipatov # git-clone http://git.altlinux.org/people/lav/packages/giter.git Source: ftp://updates.etersoft.ru/pub/Etersoft/Sisyphus/sources/tarball/%name-%version.tar BuildArchitectures: noarch Conflicts: etersoft-build-utils < 2.1 %description This package contains a set of helper utils for git and gitum. See info in Russian on %url. RECOMMENDED packages: git-core gitum %prep %setup #build #make %install # install to datadir and so on %makeinstall %find_lang %name %files -f %name.lang %doc AUTHORS %_bindir/* %changelog * Wed Feb 26 2014 Vitaly Lipatov 0.3-alt1 - gpush: add support for -a (push to all repos) - fix girar host detection * Fri Feb 14 2014 Vitaly Lipatov 0.2-alt1 - new version * Fri Jan 31 2014 Vitaly Lipatov 0.1-alt1 - initial build for ALT Linux Sisyphus giter-0.3/tests/000075500000000000000000000000001230322633100136215ustar00rootroot00000000000000giter-0.3/tests/get_web_git_repo.sh000075500000000000000000000012341230322633100174640ustar00rootroot00000000000000#!/bin/sh . `dirname $0`/../share/eterbuild/functions/common load_mod web strings repos check() { [ "$2" != "$3" ] && echo "FATAL with '$1': result '$3' do not match with '$2'" || echo "OK for '$1' with '$2'" } check git.alt "http://git.altlinux.org" $(get_git_url git.alt) check git.eter "http://git.etersoft.ru" $(get_git_url git.eter) check git.some "" $(get_git_url git.some) test_repo() { local PKGNAME=$2 local REPOPATH=$(initial_letter $PKGNAME)/$PKGNAME.git local URL=$(get_git_url $1)/$3/$REPOPATH check_url "$URL" && echo "OK with $URL" || echo "URL $URL does not exists" } test_repo git.alt testdisk gears test_repo git.alt testdisk srpms