-
Notifications
You must be signed in to change notification settings - Fork 120
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
CODENVY-1921: BitbucketServer adaptations #2000
Conversation
@skabashnyuk and @sleshchenko - can you review this? Fidelity needs this in 5.6. |
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.
updated issue description with changelog, release notes and docs link.
</dependency> | ||
</dependencies> | ||
<build> | ||
<sourceDirectory>src/main/java</sourceDirectory> |
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 think following lines are redundant
+ <sourceDirectory>src/main/java</sourceDirectory>
+ <testSourceDirectory>src/test/java</testSourceDirectory>
+ <outputDirectory>target/classes</outputDirectory>
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.
removed
@@ -87,11 +85,9 @@ private String getBaseUrl() { | |||
/** | |||
* Returns the promise which resolves authorized user information or rejects with an error. | |||
* |
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.
Extra line
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.
removed
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<sourceDirectory>src/main/java</sourceDirectory> |
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 think you can remove sourceDirectory and outputDirectory along testSourceDirectory because they have default values
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.
removed
</dependency> | ||
<dependency> | ||
<groupId>com.google.inject</groupId> | ||
<artifactId>guice</artifactId> |
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.
We use gin for gwt code. Why do we need guice dependency here? I suppose it's because usage of com.google.inject.Inject
. Can we replace them with javax.inject.Inject
and remove this dependency?
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.
com.google.inject.Singleton
is used in generated DtoClientImpls
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.
😞 OK. thanks for explanation
* @param owner | ||
* the repository owner | ||
* @param repositorySlug | ||
* the repository name |
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.
As far as I understand repository name and repository slug are different things https://github.com/codenvy/codenvy/pull/2000/files#diff-66c3fbda6d05a3029ff6c6e25921e59cR27
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.
changed description to url compatible repository name
@@ -146,7 +151,9 @@ public boolean isHostRemoteUrl(final String remoteUrl) { | |||
final BitbucketPullRequestLocation source = pullRequest.getSource(); | |||
if (author != null && source != null) { | |||
final BitbucketPullRequestBranch branch = source.getBranch(); | |||
if (username.equals(author.getUsername()) && branchName.equals(branch.getName())) { | |||
//Bitbucket Server adds '~' to authenticated user, need to substring it. | |||
String userName = username.startsWith("~") ? username.substring(1) : username; |
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.
It's hard to say that it is good practice to have userName and username variables
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.
used name
@@ -41,6 +41,11 @@ public String pullrequestUrl(String owner, String repositorySlug) { | |||
} | |||
|
|||
@Override | |||
public String updatePullrequestUrl(String owner, String repositorySlug, int pullrequestId) { |
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.
Why we can't write updatePullrequestUrl
in camel case here? I mean updatePullRequestUrl
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.
renamed
ServerException { | ||
return bitbucketConnection.updatePullRequest(owner, repositorySlug, pullRequest); | ||
} | ||
|
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.
- Please take a look https://github.com/codenvy/codenvy/pull/2000/files#diff-5e9c059cfdf4fce8aaf00131f0c424adR155 As far as I remember we've started use
vcs
instead ofgit
for service name. It can be a problem with showing such keys by IDE. Please check that IDE shows new generated keys. - As far as I understand this https://github.com/codenvy/codenvy/pull/2000/files#diff-5e9c059cfdf4fce8aaf00131f0c424adR152 won't work for bitbucket server that can have different host. Am I correct?
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.
- Changed to
vcs
. - This API method is not used in Bitbucket Server implementation.
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.
You did it in one place, but there is few more. Please do the same there. Full text search can help you 😉
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.
Thanks, changed :)
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.
ok for me.final go up to @sleshchenko
<directory>${project.build.directory}/generated-sources/dto/</directory> | ||
</resource> | ||
</resources> | ||
<testResources> |
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.
Are you sure that you need to specify it?
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.
removed
return BITBUCKET_2_0_API_URL + "/repositories/" + owner + "/" + repositorySlug + "/pullrequests"; | ||
} | ||
|
||
@Override | ||
public String updatePullRequestUrl(String owner, String repositorySlug, int pullrequestId) { |
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.
pullrequestId
-> pullRequestId
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
String pullrequestUrl(String owner, String repositorySlug); | ||
String pullRequestUrl(String owner, String repositorySlug); | ||
|
||
String updatePullRequestUrl(String owner, String repositorySlug, int pullrequestId); |
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.
pullrequestId
-> pullRequestId
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
* @throws IOException | ||
* if any i/o errors occurs | ||
* @throws BitbucketException | ||
* if Bitbucket returned unexpected or error status for request | ||
*/ | ||
public static String postJson(BitbucketConnection connection, String url, int success, String data) throws IOException, | ||
public static String postJson(BitbucketConnection connection, String url, String data) throws IOException, |
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.
exceptions list is not formatted
<build> | ||
<resources> | ||
<resource> | ||
<directory>src/main/java</directory> |
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.
Please be careful and do not add redundant sections which have the same values as default ones
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.
GWT compilation won't work without that
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.
It's not clearly. Thanks for explanation
final String projectLocation = source.getLocation(); | ||
final String projectBranch = source.getParameters().get("branch"); | ||
|
||
if (isNullOrEmpty(projectType) || isNullOrEmpty(projectLocation)) { |
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.
Can you explain link between cloneUrl
and projectType
?
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 see. Actually It is not projectType
but sourceType
. Am I right? If yes, should you check that it equals to .git
?
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.
You are right, it is redundant, simplified the check
* @param branch | ||
* the branch that the project has to match | ||
*/ | ||
boolean isCloneUrlMatching(final ProjectConfigDto project, final String cloneUrl, final String branch); |
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.
What is profit to write final for variables here?
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.
removed finals
import static com.google.common.base.Strings.isNullOrEmpty; | ||
|
||
/** | ||
* Matcher that checks clone url to be related to given project and branch. |
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.
Matcher that checks specified project to be related to given clone url and branch.
Would it better?
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.
Looks better, changed
return format(restUrl + REPOSITORY + "/pull-requests", owner, repositorySlug); | ||
} | ||
|
||
@Override | ||
public String updatePullRequestUrl(String owner, String repositorySlug, int pullrequestId) { |
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.
pullrequestId
-> pullRequestId
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.
fixed
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.
@vinokurig - can you add the milestone please? I think it's 5.7 |
What does this PR do?
client
,server
,shared
.What issues does this PR fix or reference?
#1921
Changelog
Allow PR panel and integration plugins to use BitBucket repos created from projects not just users.
Added logic in PR panel to pull from fork if user is not repo owner, otherwise from branch.
Fixed bug that prevented successful pull request from being marked correctly in UI.
Moved validate bitbucket url logic to system properties initialization step.
Divided Bitbucket Server plugin to 3 maven modules:
client
,server
,shared
.Release Notes
Enhanced BitBucket Integration Support
We have made enhancements to our BitBucket support to allow the JIRA and Jenkins integrations to use project-based repos in addition to the personal repos already supported. We have also added logic to the pull request panel inside Codenvy to issue the pull request from a fork if the user executing the pull request is not the repo owner. If the user is a repo owner the PR will be issued from the branch. Finally we have fixed a bug which resulted in a successfully executed PR from being properly marked as successful in the pull request panel UI.
Docs PR
Bugfix
codenvy/docs#103