0

The problem:
I'm using bitbucket stash (server) API in a script for my project with the {path} api method: /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/browse/{path:.*}

The idea was to save versions of config files in a repository (version01-versionXX for every config). But those configs have the same structure with different names and parameters, so when I push a new config with a commit message like 'version01' without specifying any sourceCommitId, bitbucket automatically adds a parent commit from the last file with the same structure (if it exists). As a result, in this new file's history I'm getting several 'version01' commits, which is not what I was intended to have.

What I've tried:
If I do specify sourceCommitId as the initial or the last commit on the branch, I get an error message since the file doesn't exist on this commit.

I've tried to experiment with empty sourceBranch parameter, but still some parent commit appears. The only idea I came up with is to create a new branch for every config, but this seems like overkill to me.

All attempts to find a method for editing file commit history via API also failed.

At the moment as a work around I create every config file with its name as the only line of its content and then change it to the structure I need. This works so far, but doesn't look like a good solution to me and requires 2 API requests instead of one. Is there a better way to prevent BitBucket from treating those new files as copies of old ones?

bmaegan
  • 1
  • 1

0 Answers0