hg-format-patch hg-update-subrepos \
git-hg-sub-import git-hg-sub-update \
git-repos-update-clean \
+ hv-git-functions.sh \
git-project-fetch.sh \
git-project-list.sh \
git-project-update.sh \
git-project-clone.sh \
+ git-project-tag.sh \
source-code-stats \
flac2ogg flac2mp3 \
hv-scan \
SCRIPT="`readlink -e $0`"
SCRIPTPATH=$(dirname ${SCRIPT})
-
-SUBREPOS_LIST=.gitsubrepos
+source ${SCRIPTPATH}/hv-git-functions.sh
# Uncomment to have verbose debug output
##debug=1
exit 1
fi
-if [ ! -f ${SUBREPOS_LIST} ]; then
- echo "Missing file for list of subrepos: ${SUBREPOS_LIST}"
- print_usage
- exit 1
-fi
+hv_git_validate_subrepos_list
branch_from=${1}
branch_new=${2}
clone_repo()
{
- local valid="0"
-
if [ ${#} -ne 1 ]; then
echo "Missing repository name"
exit 1
popd 1> /dev/null
}
-update_repo()
-{
- local valid="0"
-
- if [ ${#} -ne 1 ]; then
- echo "Missing repository name"
- exit 1
- fi
-
- local r=${1}
-
- echo -n "Repo ${r}: "
-
- pushd "${r}" 1> /dev/null
- b=${branch_from}
-
- exists=$(git show-ref refs/heads/${b})
- if [ -n "$exists" ]; then
- vco -q ${b} 1> /dev/null
-
- if [ ${?} -ne 0 ]; then
- rc=1
- echo "${b} (error)"
- else
- echo "${b}"
- fi
- else
- echo "${b} (not found)"
- rc=1
- fi
-
- popd 1> /dev/null
-}
-
# First, try to update all subrepos to BRANCH_FROM
-update_repo ./
-
-# Read list of repositories from file named .gitsubrepos
-while IFS=$'\n' read r ; do
- [[ "${r}" =~ \#.* ]] && continue # Skip comment lines
- [ -z ${r} ] && continue # Skip enmpty lines
-
+for r in ./ $(hv_git_get_subrepos_list); do
# Make sure directory exists
if [ ! -d "${r}" ]; then
echo "Missing repos ${r}, skipping"
continue
fi
- # Update only git repos
- if [ ! -d "${r}/.git" ]; then
- echo "Not a GIT repository"
+ hv_git_checkout ${r} ${branch_from}
+ if [ ${?} -ne 0 ]; then
+ echo "Error switching to ${branch_from} in repos ${r}"
exit 1
fi
+done
- update_repo ${r}
-done < ${SUBREPOS_LIST}
-
-if [ ${rc} -ne 0 ]; then
- echo "Error switching to branch"
- exit 1
-fi
-
-clone_repo ./
-
-# Read list of repositories from file named .gitsubrepos
-while IFS=$'\n' read r ; do
- [[ "${r}" =~ \#.* ]] && continue # Skip comment lines
- [ -z ${r} ] && continue # Skip enmpty lines
+# Then clone repo
+for r in ./ $(hv_git_get_subrepos_list); do
# Make sure directory exists
if [ ! -d "${r}" ]; then
echo "Missing repos ${r}, skipping"
continue
fi
- # Update only git repos
- if [ ! -d "${r}/.git" ]; then
- echo "Not a GIT repository"
- exit 1
- fi
-
clone_repo ${r}
-done < ${SUBREPOS_LIST}
+ rc=${?}
+done
exit ${rc}
SCRIPT="`readlink -e $0`"
SCRIPTPATH=$(dirname ${SCRIPT})
-
-SUBREPOS_LIST=.gitsubrepos
-
-# Uncomment to have verbose debug output
-##debug=1
+source ${SCRIPTPATH}/hv-git-functions.sh
print_usage()
{
exit 1
fi
-if [ ! -f ${SUBREPOS_LIST} ]; then
- echo "Missing file for list of subrepos: ${SUBREPOS_LIST}"
- print_usage
- exit 1
-fi
+hv_git_validate_subrepos_list
list_revisions()
{
local r=${1}
pushd "${r}" 1> /dev/null
- local sha=$(git log --oneline HEAD~1..HEAD)
- echo "${r}: ${sha}"
+ local sha=$(git log --abbrev=10 --pretty='format:%h %s' HEAD~1..HEAD)
+
+ local line=' '
+ printf "%s %s %s\n" ${r} "${line:${#r}}" "${sha}"
popd 1> /dev/null
}
-list_revisions ./
-
-# Read list of repositories from file named .gitsubrepos
-while IFS=$'\n' read r ; do
- [[ "${r}" =~ \#.* ]] && continue # Skip comment lines
- [ -z ${r} ] && continue # Skip enmpty lines
-
+for r in ./ $(hv_git_get_subrepos_list); do
# Make sure directory exists
if [ ! -d "${r}" ]; then
echo "Missing repos ${r}, skipping"
continue
fi
- # Update only git repos
- if [ ! -d "${r}/.git" ]; then
- echo "Not a GIT repository"
- exit 1
- fi
-
list_revisions ${r}
-done < ${SUBREPOS_LIST}
+done
--- /dev/null
+#!/bin/bash
+
+SCRIPT="`readlink -e $0`"
+SCRIPTPATH=$(dirname ${SCRIPT})
+source ${SCRIPTPATH}/hv-git-functions.sh
+
+print_usage()
+{
+ echo "$(basename $0) -- Create tag from branch"
+ echo "Usage: $(basename $0) [OPTIONS...] BRANCH TAG"
+}
+
+if [ "x${1}" = "x--help" ]; then
+ print_usage
+ exit 1
+fi
+
+if [ ${#} -ne 2 ]; then
+ echo "Missing arguments"
+ print_usage
+ exit 1
+fi
+
+hv_git_validate_subrepos_list
+
+branch_name=${1}
+tag_name=${2}
+
+for r in ./ $(hv_git_get_subrepos_list); do
+ # Make sure directory exists
+ if [ ! -d "${r}" ]; then
+ echo "${SCRIPT}: missing repos ${r}, skipping"
+ continue
+ fi
+
+ hv_git_tag_from_branch ${r} ${branch_name} ${tag_name}
+done
SCRIPT="`readlink -e $0`"
SCRIPTPATH=$(dirname ${SCRIPT})
-
-SUBREPOS_LIST=.gitsubrepos
-
-# Uncomment to have verbose debug output
-##debug=1
+source ${SCRIPTPATH}/hv-git-functions.sh
print_usage()
{
exit 1
fi
-if [ ! -f ${SUBREPOS_LIST} ]; then
- echo "Missing file for list of subrepos: ${SUBREPOS_LIST}"
- print_usage
- exit 1
-fi
+hv_git_validate_subrepos_list
branch=${1}
rc=0
-update_repo()
-{
- local valid="0"
-
- if [ ${#} -ne 1 ]; then
- echo "Missing repository name"
- exit 1
- fi
-
- local r=${1}
-
- echo -n "Repo ${r}: "
-
- pushd "${r}" 1> /dev/null
-
- for b in ${branch} latest master; do
- exists=$(git show-ref refs/heads/${b})
- if [ -n "$exists" ]; then
- vco -q ${b} 1> /dev/null
-
- if [ ${?} -ne 0 ]; then
- rc=1
- fi
- echo "${b}"
- valid="1"
- break
- fi
- done
-
- if [ x"${valid}" = x"0" ]; then
- echo "No valid branch found"
- rc=1
- fi
-
- popd 1> /dev/null
-}
-
-update_repo ./
-
-# Read list of repositories from file named .gitsubrepos
-while IFS=$'\n' read r ; do
- [[ "${r}" =~ \#.* ]] && continue # Skip comment lines
- [ -z ${r} ] && continue # Skip enmpty lines
-
+for r in ./ $(hv_git_get_subrepos_list); do
# Make sure directory exists
if [ ! -d "${r}" ]; then
echo "Skipping missing repos ${r}"
continue
fi
- # Update only git repos
- if [ ! -d "${r}/.git" ]; then
- echo "Not a GIT repository"
- exit 1
- fi
-
- update_repo ${r}
-done < ${SUBREPOS_LIST}
+ hv_git_checkout ${r} ${branch}
+ rc=${?}
+done
exit ${rc}
--- /dev/null
+#!/bin/bash
+
+# Uncomment to have verbose debug output
+#hv_git_debug=1
+
+SUBREPOS_LIST=.gitsubrepos
+
+hv_git_validate_subrepos_list()
+{
+ if [ ! -f ${SUBREPOS_LIST} ]; then
+ echo "${FUNCNAME}: missing subrepos file list: ${SUBREPOS_LIST}"
+ print_usage
+ exit 1
+ fi
+
+ # Read list of repositories from file named .gitsubrepos
+ while IFS=$'\n' read r ; do
+ [[ "${r}" =~ \#.* ]] && continue # Skip comment lines
+ [ -z ${r} ] && continue # Skip enmpty lines
+
+ # If repo directory is absent, it is ok.
+ # If repo directory is present, make sure it is a GIT repo
+ if [ -d "${r}" ]; then
+ if [ ! -d "${r}/.git" ]; then
+ echo "${FUNCNAME}: not a GIT repository: ${r}"
+ echo "BOZO=<${r}/.git>"
+ exit 1
+ fi
+ fi
+ done < ${SUBREPOS_LIST}
+
+ return 0
+}
+
+hv_git_get_subrepos_list()
+{
+ local list=""
+ local r=""
+ local IFS=""
+
+ # Read list of repositories from file named .gitsubrepos
+ while IFS=$'\n' read r ; do
+ [[ "${r}" =~ \#.* ]] && continue # Skip comment lines
+ [ -z ${r} ] && continue # Skip enmpty lines
+
+ # Add to list only if directory is present, and if it is a valid
+ # GIT repo
+ if [ -d "${r}/.git" ]; then
+ list="${list} ${r}"
+ fi
+ done < ${SUBREPOS_LIST}
+
+ echo "${list}"
+}
+
+# Arg 1: repository
+# Arg 2: branch to checkout (or tag)
+hv_git_checkout()
+{
+ if [ ${#} -ne 2 ]; then
+ echo "${FUNCNAME}: missing arguments"
+ exit 1
+ fi
+
+ local rc=0
+ local r=${1}
+ local b=${2}
+
+ echo -n "Repo ${r}: "
+
+ pushd "${r}" 1> /dev/null
+
+ exists=$(git rev-parse -q --verify ${b})
+ if [ -n "${exists}" ]; then
+ vco -q ${b} 1> /dev/null
+
+ if [ ${?} -ne 0 ]; then
+ rc=1
+ echo "${b} (error)"
+ else
+ echo "${b}"
+ fi
+ else
+ echo "${b} (not found)"
+ rc=1
+ fi
+
+ popd 1> /dev/null
+
+ return ${rc}
+}
+
+# Create a new tag in repo
+# Arg 1: repository
+# Arg 2: branch from which to create tag
+# Arg 3: new tag name
+hv_git_tag_from_branch()
+{
+ if [ ${#} -ne 3 ]; then
+ echo "${FUNCNAME}: missing arguments"
+ exit 1
+ fi
+
+ local rc=0
+ local sha=""
+ local r=${1}
+ local b=${2}
+ local tag=${3}
+
+ echo -n "Repo ${r}: "
+
+ pushd "${r}" 1> /dev/null
+
+ sha=$(git show-ref refs/heads/${b} | awk '{print $1}')
+ if [ -n "${sha}" ]; then
+ git tag ${tag} ${sha} 1> /dev/null
+ rc=${?}
+
+ if [ ${rc} -ne 0 ]; then
+ echo "${tag} (error)"
+ else
+ echo "${tag}"
+ fi
+ else
+ echo "${FUNCNAME}: branch \"${b}\" not found"
+ rc=1
+ fi
+
+ popd 1> /dev/null
+
+ return ${rc}
+}
+
+# Encore utile?
+# Arg1: repository
+hv_git_get_head_sha()
+{
+ if [ ${#} -ne 1 ]; then
+ echo "Missing repository name"
+ exit 1
+ fi
+
+ local r=${1}
+
+ pushd "${r}" 1> /dev/null
+ local sha=$(git log --pretty='format:%H' HEAD~1..HEAD)
+ echo "${sha}"
+ popd 1> /dev/null
+}