Skip to content
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

Merged
merged 13 commits into from
Mar 31, 2017
Merged

CODENVY-1921: BitbucketServer adaptations #2000

merged 13 commits into from
Mar 31, 2017

Conversation

vinokurig
Copy link
Contributor

@vinokurig vinokurig commented Mar 28, 2017

What does this PR do?

  1. Fixed method that gets authorized Bitbucket Server user and fixed the Bitbucket Pull Request plugin to be able to make pull requests from forks if user != repo owner, otherwise from branch.
  2. Implemented 'update Pull Request' logic in Bitbucket and Bitbucket Server plugins.
  3. Fixed bug when successful update pull request step was not marked as successful in UI.
  4. Rework Bitbucket Server Integration plugin to be able to work with repositories created from project.
  5. Moved validate bitbucket url logic to the step of system properties initialization.
  6. Divided Bitbucket Server plugin to 3 maven modules: 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

@bmicklea
Copy link
Contributor

@skabashnyuk and @sleshchenko - can you review this? Fidelity needs this in 5.6.

Copy link
Contributor

@bmicklea bmicklea left a 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.

@bmicklea bmicklea added this to the 5.6.0 milestone Mar 28, 2017
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
Copy link
Contributor

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>

Copy link
Contributor Author

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.
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra line

Copy link
Contributor Author

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>
Copy link
Contributor

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

Copy link
Contributor Author

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>
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor Author

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;
Copy link
Contributor

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

Copy link
Contributor Author

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) {
Copy link
Contributor

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

Copy link
Contributor Author

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);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 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 of git for service name. It can be a problem with showing such keys by IDE. Please check that IDE shows new generated keys.
  2. 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Changed to vcs.
  2. This API method is not used in Bitbucket Server implementation.

Copy link
Contributor

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 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, changed :)

Copy link
Contributor

@skabashnyuk skabashnyuk left a 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>
Copy link
Contributor

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?

Copy link
Contributor Author

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pullrequestId -> pullRequestId

Copy link
Contributor Author

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pullrequestId -> pullRequestId

Copy link
Contributor Author

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,
Copy link
Contributor

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>
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

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)) {
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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);
Copy link
Contributor

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?

Copy link
Contributor Author

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.
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks better, changed

@riuvshin riuvshin removed this from the 5.6.0 milestone Mar 29, 2017
return format(restUrl + REPOSITORY + "/pull-requests", owner, repositorySlug);
}

@Override
public String updatePullRequestUrl(String owner, String repositorySlug, int pullrequestId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pullrequestId -> pullRequestId

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Contributor

@sleshchenko sleshchenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vinokurig vinokurig merged commit aaebfbb into master Mar 31, 2017
@vinokurig vinokurig deleted the CODENVY-1921 branch March 31, 2017 13:04
@bmicklea
Copy link
Contributor

@vinokurig - can you add the milestone please? I think it's 5.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants