It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get the change set ID in VcsRepositoryViewer's getWebRepositoryUrlForFileDiff?

Chris Pickett Apr 17, 2017

I'm trying to implement VcsRepositoryViewer for Perforce Swarm. The only way Swarm can display diffs for a file revision is on the same page that shows the commit that the file revision was part of. Because of this, I need access to both the filename and change set ID in order to generate the appropriate link to view diffs. getWebRepositoryUrlForFileDiff() currently only has access to the filename and revision.

I can return null from getWebRepositoryUrlForFileDiff() to hide the "(diffs)" link for now, but it would be great if we could get the diff link working without supplying our own template to replace the built-in one.

Is there any way to get access to the change set ID in this function? I realize the design of this new plugin point was to be stateless, so I assume not, but we'd really like to get this working if possible. The problem seems to be that defaultCommitView.ftl has

[#local fileDiffUrl = linkGenerator.getWebRepositoryUrlForFileDiff(file, repositoryData)!/]
[#if fileDiffUrl?has_content]
    <a href="${fileDiffUrl}">(diffs)</a>
[/#if]


coded into it so unless we replace the template with our own, I don't see how to do this right now.

Any feedback would be appreciated!

1 answer

1 accepted

0 votes
Answer accepted
Marcin Gardias Atlassian Team Apr 18, 2017
  if (file.isRevisionKnown())
        {
            String revision = file.getRevision();
}
Chris Pickett Apr 18, 2017

Thanks for contributing, but Perforce separates the concept of file revision from commit ID, so revision 2 of a file could be in commit 1000. In that example, the 1000 (commit.getChangeSetId()) is the part I'd need while I currently only have the 2.

Chris Pickett Apr 26, 2017

If this is not something that's currently possible, where can I enter a feature request to get it added?

Marcin Gardias Atlassian Team Apr 29, 2017 • edited

> revision 2 of a file could be in commit 1000.

Please help me understand, are you saying that file changed in commit 1000 can have revision number 2?

As you can imagine, usually it's not the case. Do you use Bamboo's built-in Perforce plugin to generate the changelists or something else?

Update: you probably don't, because in our Perforce plugin we deliberately ignore file revisions when creating CommitFile objects and set file revision to commit revision. If you are developer of Perforce Swarp repository plugin, then perhaps the easiest thing is to do the same.

I opened this improvement request to fix our API: https://jira.atlassian.com/browse/BAM-18354

Chris Pickett Apr 29, 2017

> Please help me understand, are you saying that file changed in commit 1000 can have revision number 2?

Yes, that's exactly correct.

> Do you use Bamboo's built-in Perforce plugin to generate the changelists or something else?

We have written our own Perforce plugin to fully support Perforce Streams using the new VCS plugin points in Bamboo 5.14. I hope to be able to release it once we've completed work on it.

> If you are developer of Perforce Swarp repository plugin, then perhaps the easiest thing is to do the same.

It's important to us to be able to separate file revision from commit ID because the two are distinct and each has its use in Perforce. I also use Git so I understand that other VCS's handle things differently. :)

> I opened this improvement request to fix our API: https://jira.atlassian.com/browse/BAM-18354

Thank you!

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in Statuspage

⭐️Would you recommend Statuspage? Leave a (honest!) review. ⭐️

Hi Community friends, We're working on sourcing more reviews on Capterra – a popular software review site –  to help teams like yours make more informed decisions when choosing an inc...

80 views 3 5
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you