是否有用于获取文件夹中文件的文件上次修改日期的 TFS Git API?
Is there a TFS Git API for getting file last modified date of files in a folder?
我正在使用 TFS Git API 以编程方式从我的 Git 存储库中读取数据。
我有这样的要求,我需要能够从 git 存储库中获取一个文件夹并列出其中的所有文件及其最后修改的时间戳。
我正在使用项目 api 并且我能够通过此请求获取文件夹中的项目:
https://docs.microsoft.com/en-us/rest/api/azure/devops/git/items/list?view=azure-devops-rest-5.1
例如:
GET https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/items?scopePath=/MyWebSite/MyWebSite/Views&recursionLevel=Full&includeContentMetadata=true&api-version=5.1
这能够获取项目 URL,但无法包含时间戳。
所以我认为这 api 行不通。
我需要打电话给其他人 api 才能获得此信息吗?
我没有看到 REST API 到 return 时间戳。相反,您可以将 repo 克隆到本地,并使用以下命令输出时间戳:
git log -1 --pretty="format:%ci" -- path
要输出所有带时间戳的文件,请尝试以下脚本:
git ls-tree -r --name-only HEAD | while read filename; do
echo "$(git log -1 --format="%ci" -- $filename) $filename"
done
我正在使用 TFS Git API 以编程方式从我的 Git 存储库中读取数据。
我有这样的要求,我需要能够从 git 存储库中获取一个文件夹并列出其中的所有文件及其最后修改的时间戳。
我正在使用项目 api 并且我能够通过此请求获取文件夹中的项目:
https://docs.microsoft.com/en-us/rest/api/azure/devops/git/items/list?view=azure-devops-rest-5.1
例如:
GET https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/items?scopePath=/MyWebSite/MyWebSite/Views&recursionLevel=Full&includeContentMetadata=true&api-version=5.1
这能够获取项目 URL,但无法包含时间戳。
所以我认为这 api 行不通。
我需要打电话给其他人 api 才能获得此信息吗?
我没有看到 REST API 到 return 时间戳。相反,您可以将 repo 克隆到本地,并使用以下命令输出时间戳:
git log -1 --pretty="format:%ci" -- path
要输出所有带时间戳的文件,请尝试以下脚本:
git ls-tree -r --name-only HEAD | while read filename; do
echo "$(git log -1 --format="%ci" -- $filename) $filename"
done