【发布时间】:2018-05-03 12:56:33
【问题描述】:
给定 2 个 git 存储库(产品 A 和产品 B),带有子模块(CommonSubmodule、SomeOtherSubmodule)
D:\Repositories\ProductA\
D:\Repositories\ProductA\CommonSubmodule
D:\Repositories\ProductA\SomeOtherSubmodule
D:\Repositories\ProductA\SomeOtherSubmodule\
D:\Repositories\ProductB\SomeOtherSubmodule\
D:\Repositories\ProductB\CommonSubmodule\
我在网上找到了一个脚本,它允许通过 post_checkout 挂钩记录分支
#!/bin/sh
previous_head_ref=$1
new_head_ref=$2
is_branch_checkout=$3
if [[ "$previous_head_ref" != "$new_head_ref" ]] && [[ "$is_branch_checkout" == 1 ]]; then
branch=$(git rev-parse --abbrev-ref HEAD)
#if [[ "develop" != "$branch" ]]; then
path="$(dirname "$0")/.."
logfile="$path/x_branch_log"
ts=$(date +%s)
echo "$branch|1|$ts" >> $logfile
echo "Logging $branch|1|$ts to $logfile"
echo PWD is $PWD
#fi
fi
在 post_checkout 上下文中,如何在不编码绝对路径的情况下获取根目录 (D:\Repositories)?
D:\Repositories\
另外,如何获取产品根目录,例如
D:\Repositories\ProductA\
D:\Repositories\ProductB\
【问题讨论】: