所以,等了一会儿,似乎没有答案,但是,既然你已经在这里了......让我们避免这种情况
所以在这里你有一段 bash 代码来生成一个表格,其中包含文件中的日期与提取的数据和项目的提交之间的相关性。
可能不是最好的方法,也不是最快的方法,但它会给你你所需要的:)
保存在 file.sh 中并用作:./file.sh GithubUser/ProjectName YourFileWithTheExtractedData.csv
#!/bin/bash
gitproject="git@github.com:${1}.git"
gitfolder=$(echo $gitproject | sed -E 's/(.+)\/(.+\.git$)/\2/g')
workdir="$(pwd)"
measuresFile=$2
if [ ! -d "$workdir/$gitfolder" ];
then
$(git -C $workdir clone -q --bare $gitproject)
fi
echo '"sonar-timestamp","git-timestamp","commit-hash"' >> $workdir/Hashes_$2
cat $workdir/$measuresFile | grep -Eo '"[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}T[[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}\+[[:digit:]]{4}",' | sed -E 's/"|",//g' | sort -u >> $workdir/TMP_Hashes_$2
for i in $( cat $workdir/TMP_Hashes_$2 | sort -u ); do echo $(echo $i | date '+%s' -f - ),"$i" >> $workdir/Hashes_$2 ; done
rm -rf $workdir/TMP_Hashes_$2
gHashes=( $(TZ=Europe/London git -C $workdir/$gitfolder log --all --date=format-local:%Y-%m-%dT%H:%M:%S%z --format=%ad\ %H | sort | tr '\n' ' ') )
COUNTER=0
while (("$COUNTER" < "${#gHashes[@]}"))
do
sust=$(date -d "${gHashes[$COUNTER]}" '+%s')
notInc=$(cat $workdir/Hashes_$2 | grep -o "^${sust}" | wc -l )
$(sed -i -E "s/(^${sust}),(.+)/\"\2\",\"${gHashes[($COUNTER)]}\",\"${gHashes[($COUNTER + 1)]}\"/g" $workdir/Hashes_$2)
if (( "$notInc" == "0" ));
then
rHashes+=( "${gHashes[($COUNTER)]}" "${gHashes[($COUNTER + 1)]}" )
fi
let COUNTER=COUNTER+2
done
$(sed -i -E "s/(^[0-9]+),(.+)/\"\2\",\"\",\"\"/g" $workdir/Hashes_$2)
COUNTER=0
while (("$COUNTER" < "${#rHashes[@]}"))
do
echo "\"\",\"${rHashes[($COUNTER)]}\",\"${rHashes[($COUNTER + 1)]}\"" >> $workdir/Hashes_$2
let COUNTER=COUNTER+2
done