New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bitbucket enterprise support #246
Bitbucket enterprise support #246
Conversation
@adam-sajdak Are you able to sign the CLA? |
@ctaggart Is there something that can be done in case @adam-sajdak is unable to sign it? Me and a bunch of other people seem to eagerly wait for this feature to be released. |
@walliski I don't think there is, other than reimplement it in a new PR. |
Hello, |
… ssh repository uri.
@adam-sajdak Friendly reminder. |
@adam-sajdak, it has been a month since we last heard from you and two months since this pull request was opened. Is legal still holding up things? |
@adam-sajdak Can you estimate when/if you will be able to sign the CLA? |
…tbucket_Enterprise_Support # Conflicts: # src/SourceLink.Bitbucket.Git/build/Microsoft.SourceLink.Bitbucket.Git.props # src/SourceLink.Bitbucket.Git/buildCrossTargeting/Microsoft.SourceLink.Bitbucket.Git.props
Hi sorry for big delay I finally signed CLA. |
Cool, I'll take a look. |
README.md
Outdated
|
||
```xml | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.SourceLink.Bitbucket.Git" Version="1.0.0-beta2-18618-05" PrivateAssets="All"/> | ||
<SourceLinkBitbucketGitHost Include="bitbucket.org" EnterpriseEdition="true" Version="4.1" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[](start = 2, length = 93)
This should be default. Customer who uses repository hosted on bitbucket.org shouldn't need to specify anything in their project file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using a server hosted in different domain we should default to enterprise edition and the latest version with the option to specify an older version.
In reply to: 280532565 [](ancestors = 280532565)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Now for bitbucket.org cloud hosting there is no need to provide SourceLinkBitbucketGitHost configuration in csproj.
When the domain is different than bitbucket.org it defaults to enterprise edition and the latest version.
protected override bool SupportsImplicitHost => false; | ||
|
||
protected override string BuildSourceLinkUrl(Uri contentUri, Uri gitUri, string relativeUrl, string revisionId, | ||
ITaskItem hostItem) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ITaskItem hostItem [](start = 12, length = 18)
Style: keep the parameter on the previous line. We either indent all parameters or none.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕐
Any idea, how long will it take to get released. |
I am in the middle of changes code review comments and I will update pull request tomorrow. |
Adding SourceLinkBitbucketGitHost is not necessary for cloud scenario For self-hosting scenario adding SourceLinkBitbucketGitHost with proper host is required EnterpriseEdition and Version settings are optional with default values.
@tmat |
README.md
Outdated
|
||
```xml | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.SourceLink.Bitbucket.Git" Version="1.0.0-beta2-18618-05" PrivateAssets="All"/> | ||
</ItemGroup> | ||
``` | ||
|
||
For self-hosted Bitbucket projects reference [Microsoft.SourceLink.Bitbucket.Git](https://www.nuget.org/packages/Microsoft.SourceLink.Bitbucket.Git) package and add Bitbucket host configuration. | ||
Additionally there are two optional attributes with default values: | ||
EnterpriseEdition="true" - flag whether it is Enterprise Edtition or Cloud Edition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edtition [](start = 57, length = 8)
typo: Edtition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think markdown will format these as you intended - on separate lines.
In reply to: 283563555 [](ancestors = 283563555)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's include the EnterpriseEdition and Version parameters to the example below.
In reply to: 283563725 [](ancestors = 283563725,283563555)
private const string VersionMetadataName = "Version"; | ||
private const string VersionWithNewUrlFormat = "4.7"; | ||
|
||
protected override bool SupportsImplicitHost => false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SupportsImplicitHost [](start = 32, length = 20)
If you keep this set to true
(the default) it won't be necessary to specify the host, unless the user needs to specify the version and edition. I think that would be better. Specifying the domain when the defaults are used is unnecessary.
@@ -13,7 +13,7 @@ public BitBucketGitTests() | |||
} | |||
|
|||
[ConditionalFact(typeof(DotNetSdkAvailable))] | |||
public void FullValidation_Https() | |||
public void FullValidation_CloudHttps() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FullValidation_CloudHttps [](start = 20, length = 25)
This is odd - we say that the default is EnterpriseEdition="true", but the bitbucket.org
host specified in src\SourceLink.Bitbucket.Git\build\Microsoft.SourceLink.Bitbucket.Git.props
should be using the Cloud Edition URl format, right?
Shouldn't the SourceLinkBitbucketGitHost
for bitbucket.org
have EnterpriseEdition="false"
?
<SourceLinkBitbucketGitHost Include="bitbucket.org" EnterpriseEdition="false" />
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see, you're special casing bitbucket.org
in the code:
if (!BitbucketCloudHostingUrl.Equals(gitUri.GetHost(), StringComparison.OrdinalIgnoreCase))
We can remove that special case and specify the property in the props file directly.
In reply to: 283574378 [](ancestors = 283574378)
protected override string BuildSourceLinkUrl(Uri contentUri, Uri gitUri, string relativeUrl, string revisionId, ITaskItem hostItem) | ||
=> UriUtilities.Combine(UriUtilities.Combine(contentUri.ToString(), relativeUrl), "raw/" + revisionId + "/*"); | ||
{ | ||
var isEnterpriseEditionFlagAvailable = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isEnterpriseEditionFlagAvailable [](start = 16, length = 32)
This can be simplified as
return boo.TryParse(..., out var isEnterpriseEditionValue) && isEnterpriseEditionValue ?
BuildSourceLinkUrlForEnterpriseEdition(contentUri, relativeUrl, revisionId, hostItem) :
BuildSourceLinkUrlForCloudEdition(contentUri, relativeUrl, revisionId);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tmat I modified pull request according to your suggestions.
- Now the
SourceLinkBitbucketGitHost
for bitbucket.org in props haveEnterpriseEdition="false"
- Removed
SupportsImplicitHost => false;
- I had to check if
hostItem
is null. It is null ifSourceLinkBitbucketGitHost
does not match actual git url host.
Bottom line, now it will be not necessary to put SourceLinkBitbucketGitHost
in csproj(unless you want to set specifiv Version attribute) and it will work for both cloud and enterprise scenarios.
Add EnterpriseEdition="false" in defaulp props file so Bitbucket.org is recognized as cloud version By default EnterpriseEdition is true so any other bitbucket repository is recognized as enterprise version by default
Looks great. Thanks for making all the changes. I'm wondering if we could simplify a bit further. It just occurred to me that since the version is only relevant for Enterprise Edition, we could just have a single attribute |
Great, thank you. For me the current state is fine and I think we can merge it. Could you do it @tmat ? |
@adam-sajdak Thanks! |
@tmat Would it be possible to get a new release with these changes? |
+1 |
@walliski @kvskranthikumar Here it is: Could you test it works for you? |
I have verified the fix, it is working perfectly :)
When will this be released to nuget.org, currentlly the version available on nuget.org is 1.0.0-beta2-18618-05 |
I'll publish is asap. Just wanted to double check it works. Glad to hear it does. |
A bit confused about the names "Enterprise Edition" vs "Cloud Edition". Based on https://confluence.atlassian.com/confeval/development-tools-evaluator-resources/bitbucket/bitbucket-what-is-bitbucket my understanding is that Cloud Edition is the one running on bitbucket.org and never self-hosted. Enterprise Edition would be either Bitbucket Server or Bitbucket Data Center. Is that correct? |
BTW, the packages are now available on nuget.org: https://www.nuget.org/packages?q=Microsoft.SourceLink |
"Cloud Edition" is Bitbucket Cloud, so the one hosted on Atlassian's bitbucket.org. |
That's my understanding now as well. I have already updated the readme. |
Add support for Bitbucket Enterprise Edition.