使用文件名/路径获取特定文件的提交ID – Bitbucket Server API

huangapple go评论85阅读模式
英文:

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="文件路径"

文档链接:
https://developer.atlassian.com/server/bitbucket/rest/v811/api-group-repository/#api-api-latest-projects-projectkey-repos-repositoryslug-commits-get

英文:

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"

Documentation:
https://developer.atlassian.com/server/bitbucket/rest/v811/api-group-repository/#api-api-latest-projects-projectkey-repos-repositoryslug-commits-get

答案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"

huangapple
  • 本文由 发表于 2023年6月15日 21:36:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76483062.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定