英文:
Getting Commit ID on a specific file using file name/path - Bitbucket Server API
问题
我正在尝试编写一些脚本,用于在Bitbucket Server中创建文件(json),并偶尔更新这些文件。后来,我想要能够查询对文件所做的更改以及添加/删除了什么。
目前,我一直在使用产品供应商提供的API文档上的CURL示例进行测试。我已经能够创建一个新文件,但我注意到要更新此文件,您需要指定sourceCommitId。
我的问题是,如果我不知道sourceCommitId,只知道文件名,我如何获得这个sourceCommitId?
我应该如何实现这一点?
如果我查看文档,有一个指定路径的选项,但是如果我将Bitbucket上的文件路径放入其中,它会返回空。
例如,GET /rest/api/latest/projects/{projectKey}/repos/{repositorySlug}/commits?path="文件路径"
英文:
I am trying to write some scripts which will create files(json) in Bitbucket Server and occasionally update these files. Later on I would like to be able to query the changes made to the files and what was added/removed.
For now i have been testing with the CURL examples on the API documentation provided by the product vendor. I have been able to create a new file, however i notice to update this file, you need to specify the sourceCommitId.
My question is, how do I get this sourceCommitId, if I don't know it and just know the file name?
How do I achieve this?
If I look at the documentation, there is an option to specify path, however if i put the file path from bitbucket it returns nothing.
e.g. GET /rest/api/latest/projects/{projectKey}/repos/{repositorySlug}/commits?path="filepath"
答案1
得分: 1
已解决,提交后需要加一个斜杠,查询结构如下 -
GET /rest/api/latest/projects/{projectKey}/repos/{repositorySlug}/commits/?path="filepath"
英文:
This is resolved, there needs to be a slash after commits, the query structure is like this -
GET /rest/api/latest/projects/{projectKey}/repos/{repositorySlug}/commits/?path="filepath"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论