Commit 37e713fa authored by Vitaly Lipatov's avatar Vitaly Lipatov

2.1.0-alt1

- move all git specific command to the giter package
parent 9b416384
#!/bin/sh
# Do commit --amend for all files in the repo
# load common functions, compatible with local and installed script
. `dirname $0`/../share/eterbuild/functions/common
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 1
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 $@
......@@ -5,17 +5,14 @@
. `dirname $0`/../share/eterbuild/functions/common
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "gammit - do fast git commit amend (apply all current changes to the last commit)"
echo "Use: gammit [-e] [file]"
echo " -e - edit commit message"
exit 1
echo "gammit - make commit with description from last changelog entry in spec"
echo "Use: gammit"
exit 0
fi
ARG=
# If no args
if [ -z "$1" ] ; then
ARG="$ARG -a"
ARG="ARG -a"
fi
docmd gear-commit $ARG $@
#!/bin/sh
# load common functions, compatible with local and installed script
. `dirname $0`/../share/eterbuild/functions/common
load_mod git
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 1
fi
if is_girar_name $1 ; then
GIRARHOST=$1
shift
fi
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."
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
#!/bin/sh
# load common functions, compatible with local and installed script
. `dirname $0`/../share/eterbuild/functions/common
load_mod git
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 1
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
#!/bin/sh
# load common functions, compatible with local and installed script
. `dirname $0`/../share/eterbuild/functions/common
load_mod git
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] [-t|--tags] [tag]"
function mygetopts()
{
name=${0##*/}
Descr="$name - publish current project repo remote git repo"
phelp()
{
echog "$Descr"
echog "$Usage"
echog "Options:"
echog " -f - force push"
echog " -a - push all branches"
echog " -t - push all tags"
}
while getopts :hfat opt; do
case $opt in
h) phelp; exit 0;;
f) PUSHFORCE="--force" ;;
a) PUSHALL="--all" ;;
t) TAGSALL="--tags" ;;
+?) echog "$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)
}
# 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$PUSHALL" ] && 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)"
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 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 [ "$PUSHALL" = "--all" ] ; 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
#!/bin/sh
# Do git rebase -i
# load common functions, compatible with local and installed script
. `dirname $0`/../share/eterbuild/functions/common
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "grebase - do interactive rebase"
echo "Use: grebase [N]"
exit 1
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
#!/bin/sh
# load common functions, compatible with local and installed script
. `dirname $0`/../share/eterbuild/functions/common
load_mod rpm git girar
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 1
fi
if is_girar_name $1 ; then
GIRARHOST=$1
shift
fi
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)
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
# NOTE: do not use clean_spec or rpmcs for this spec
Name: etersoft-build-utils
Version: 2.0.29
Version: 2.1.0
Release: alt1
Summary: A set of rpm build utilities from Etersoft
......@@ -22,6 +22,7 @@ BuildArchitectures: noarch
# Buildreqs note: C compiler is required by rpm-build; we do not require C++ here
BuildRequires: rpm-build-compat >= %altcompat_ver
Requires: giter >= 0.1
Requires: eepm >= 1.3.0
Requires: erc >= 0.3
......@@ -69,6 +70,9 @@ RECOMMENDED packages: gcc-c++ perl-libwww ccache elinks mutt hasher curl
%config(noreplace) %_sysconfdir/eterbuild/repos/*
%changelog
* Sat Feb 01 2014 Vitaly Lipatov <lav@altlinux.ru> 2.1.0-alt1
- move all git specific command to the giter package
* Mon Oct 21 2013 Vitaly Lipatov <lav@altlinux.ru> 2.0.29-alt1
- gremote, rpmgp: use get_girar_repo func
- rpmpub: add sources to target dir if missed
......
......@@ -3,7 +3,7 @@
# Author: Vitaly Lipatov <lav@etersoft.ru>
# Public domain
ETERBUILDVERSION=2027
ETERBUILDVERSION=2100
SUDO="sudo"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment