From 30ad9ca62d3e47f6f806538d7b733dbab67710f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Thu, 5 Jan 2023 08:01:48 +0100 Subject: core: rename script git-version.sh to set_git_version.sh --- tools/git-version.sh | 73 ------------------------------------------------ tools/set_git_version.sh | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 73 deletions(-) delete mode 100755 tools/git-version.sh create mode 100755 tools/set_git_version.sh (limited to 'tools') diff --git a/tools/git-version.sh b/tools/git-version.sh deleted file mode 100755 index a983a5dac..000000000 --- a/tools/git-version.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2003-2023 Sébastien Helleu -# -# This file is part of WeeChat, the extensible chat client. -# -# WeeChat is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# WeeChat 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with WeeChat. If not, see . -# - -# -# Updates git version in config-git.h if the output of "git describe" has changed. -# -# Syntax: -# git-version.sh -# -# rootdir : root directory with WeeChat files (to search .git/ directory) -# version : WeeChat version, for example 0.3.9 or 0.4.0-dev -# headerfile: file to update, for example config-git.h -# - -if [ $# -lt 3 ]; then - echo "Syntax: $0 " - exit 1 -fi - -ROOTDIR=$1 -VERSION=$2 -HEADERFILE=$3 - -# debug: -#echo "pwd=$PWD, rootdir=$ROOTDIR, version=$VERSION, headerfile=$HEADERFILE" - -# read git version if we are in a devel/rc version and if we are in a repository -GIT_VERSION="" -case ${VERSION} in -*-*) - # devel/rc version (like 0.4.0-dev or 0.4.0-rc1) - if [ -d "${ROOTDIR}/.git" ]; then - GIT_VERSION=$(cd "${ROOTDIR}" && git describe 2>/dev/null) - fi - ;; -*) - # stable version => no git version - ;; -esac - -# check if git version has changed -if [ ! -f "${HEADERFILE}" ]; then - # header does not exist => create it - echo "Creating file ${HEADERFILE} with git version: \"${GIT_VERSION}\"" - echo "#define PACKAGE_VERSION_GIT \"${GIT_VERSION}\"" >"${HEADERFILE}" -else - if grep -q "#define PACKAGE_VERSION_GIT \"${GIT_VERSION}\"" "${HEADERFILE}"; then - # git version matches the file => NO update - echo "File ${HEADERFILE} is up-to-date (git version: \"${GIT_VERSION}\")" - else - # git version not found in file => update file with this git version - echo "Updating file ${HEADERFILE} with git version: \"${GIT_VERSION}\"" - sed "s/#define PACKAGE_VERSION_GIT \".*\"/#define PACKAGE_VERSION_GIT \"${GIT_VERSION}\"/" "${HEADERFILE}" >"${HEADERFILE}.tmp" - mv -f "${HEADERFILE}.tmp" "${HEADERFILE}" - fi -fi diff --git a/tools/set_git_version.sh b/tools/set_git_version.sh new file mode 100755 index 000000000..fb2293be0 --- /dev/null +++ b/tools/set_git_version.sh @@ -0,0 +1,73 @@ +#!/bin/sh +# +# Copyright (C) 2003-2023 Sébastien Helleu +# +# This file is part of WeeChat, the extensible chat client. +# +# WeeChat is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# WeeChat 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with WeeChat. If not, see . +# + +# +# Updates git version in config-git.h if the output of "git describe" has changed. +# +# Syntax: +# set_git_version.sh +# +# rootdir : root directory with WeeChat files (to search .git/ directory) +# version : WeeChat version, for example 0.3.9 or 0.4.0-dev +# headerfile: file to update, for example config-git.h +# + +if [ $# -lt 3 ]; then + echo "Syntax: $0 " + exit 1 +fi + +ROOTDIR=$1 +VERSION=$2 +HEADERFILE=$3 + +# debug: +#echo "pwd=$PWD, rootdir=$ROOTDIR, version=$VERSION, headerfile=$HEADERFILE" + +# read git version if we are in a devel/rc version and if we are in a repository +GIT_VERSION="" +case ${VERSION} in +*-*) + # devel/rc version (like 0.4.0-dev or 0.4.0-rc1) + if [ -d "${ROOTDIR}/.git" ]; then + GIT_VERSION=$(cd "${ROOTDIR}" && git describe 2>/dev/null) + fi + ;; +*) + # stable version => no git version + ;; +esac + +# check if git version has changed +if [ ! -f "${HEADERFILE}" ]; then + # header does not exist => create it + echo "Creating file ${HEADERFILE} with git version: \"${GIT_VERSION}\"" + echo "#define PACKAGE_VERSION_GIT \"${GIT_VERSION}\"" >"${HEADERFILE}" +else + if grep -q "#define PACKAGE_VERSION_GIT \"${GIT_VERSION}\"" "${HEADERFILE}"; then + # git version matches the file => NO update + echo "File ${HEADERFILE} is up-to-date (git version: \"${GIT_VERSION}\")" + else + # git version not found in file => update file with this git version + echo "Updating file ${HEADERFILE} with git version: \"${GIT_VERSION}\"" + sed "s/#define PACKAGE_VERSION_GIT \".*\"/#define PACKAGE_VERSION_GIT \"${GIT_VERSION}\"/" "${HEADERFILE}" >"${HEADERFILE}.tmp" + mv -f "${HEADERFILE}.tmp" "${HEADERFILE}" + fi +fi -- cgit v1.2.3