Re: [PATCH -perfbook] autodate.sh: Add graceful fallback of commitid-only mode for shallow clone

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Feb 04, 2023 at 12:23:25AM +0900, Akira Yokosawa wrote:
> Under shallow clone of perfbook repo, "git describe" can't work.
> Catch the error and use "git log" to obtain the commit id instead.
> 
> Following is the comparison of autodate.tex. 
> 
> Before:
> 
>     \date{February 3, 2023 \\ Tag: \texttt{} }
>     \newcommand{\commityear}{2023}
>     \newcommand{\commitid}{}
>     \IfQqzBg{}{\setboolean{qqzbg}{false}}
>     % tcolorbox version: 5.1
>     \tcbsetforeverylayer{autoparskip}
> 
> After:
> 
>     \date{February 3, 2023 \\ Commit: \texttt{g25bd138c30bf} (shallow clone) }
>     \newcommand{\commityear}{2023}
>     \newcommand{\commitid}{g25bd138c30bf}
>     \IfQqzBg{}{\setboolean{qqzbg}{false}}
>     % tcolorbox version: 5.1
>     \tcbsetforeverylayer{autoparskip}
> 
> Signed-off-by: Akira Yokosawa <akiyks@xxxxxxxxx>
> Cc: Leonardo Bras <leobras.c@xxxxxxxxx>

Thank you, Akira, and I have queued this.

Leonardo, could you please check to see whether this works for you in
your particular environment?  If it does, please include something
like this in your reply:

Tested-by: Leonardo Bras <leobras.c@xxxxxxxxx>

							Thanx, Paul

> ---
>  utilities/autodate.sh | 54 ++++++++++++++++++++++++-------------------
>  1 file changed, 30 insertions(+), 24 deletions(-)
> 
> diff --git a/utilities/autodate.sh b/utilities/autodate.sh
> index e33c254d917f..6d10b5d7d2b4 100644
> --- a/utilities/autodate.sh
> +++ b/utilities/autodate.sh
> @@ -52,27 +52,28 @@ else
>  	else
>  		modified=""
>  	fi
> -	description="`git describe --tags HEAD`"
> -	case "$description" in
> -	*-g*)
> -		release=`env printf 'Commit: \\\texttt{%s}' "$description"`
> -		commitid="$description"
> -		;;
> -	v*)
> -		release="Release $description"
> -		commitid=$description
> -		qqzbg="true"
> -		;;
> -	Edition*)
> -		release="Edition"
> -		commitid=$description
> -		qqzbg="true"
> +	if description="`git describe --tags HEAD 2> /dev/null`"
> +	then
>  		case "$description" in
> -		*P*)
> -			release="Print $release"
> +		*-g*)
> +			release=`env printf 'Commit: \\\texttt{%s}' "$description"`
> +			commitid="$description"
>  			;;
> -		esac
> -		case "$description" in
> +		v*)
> +			release="Release $description"
> +			commitid=$description
> +			qqzbg="true"
> +			;;
> +		Edition*)
> +			release="Edition"
> +			commitid=$description
> +			qqzbg="true"
> +			case "$description" in
> +			*P*)
> +				release="Print $release"
> +				;;
> +			esac
> +			case "$description" in
>  		Edition[.-][0-9]*)
>  			ednum="`echo $description | sed -e 's/^Edition[.-]\([0-9]*\).*$/\1/'`"
>  			release=`env printf '\\Ordinalstringnum{%s} %s' $ednum "$release"`
> @@ -85,11 +86,16 @@ else
>  			;;
>  		esac
>  		;;
> -	*)
> -		release=`env printf 'Tag: \\\texttt{%s}' "$description"`
> -		commitid=`echo $description | sed -e 's/.*-\(g.*\)/\1/'`
> -		;;
> -	esac
> +		*)
> +			release=`env printf 'Tag: \\\texttt{%s}' "$description"`
> +			commitid=`echo $description | sed -e 's/.*-\(g.*\)/\1/'`
> +			;;
> +		esac
> +	else
> +		description=`git log --max-count=1 | head -n 1 | sed -e 's/^commit \([0-9a-f]\{12\}\).*$/g\1/'`
> +		release=`env printf 'Commit: \\\texttt{%s} (shallow clone)' "$description"`
> +		commitid="$description"
> +	fi
>  fi
>  month=`date --date="$date_str" +%B`
>  year=`date --date="$date_str" +%Y`
> 
> base-commit: 3bfa0a092334e3a82bf75217b01d500ad78b6dc5
> -- 
> 2.25.1
> 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux