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

Update to the 5.0 APIs, and now pass in the quarantine environment variables #56

Merged
merged 1 commit into from
Mar 30, 2018

Conversation

itay
Copy link
Contributor

@itay itay commented Aug 18, 2017

I've updated the code to properly use the new 5.0 hook APIs, as well as pass in the environment variables. This will make it work with the newer versions of Git.

I'm not sure how to properly update the pom.xml here, so I will leave that to @seletskiy or someone else who can suggest. The plugin may need to be marked as 5.0+ only now as well, though I'm not sure.

@bturner if you're able to take a look and give feedback, that would be very welcome.

@seletskiy
Copy link
Member

seletskiy commented Aug 18, 2017

@itay: Please, make PR to https://github.com/seletskiy/atlassian-external-hooks, I do not have access to current repo anymore.

Copy link

@bturner bturner left a comment

Choose a reason for hiding this comment

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

The changes look correct to me, in terms of how the SPI is updated.

Merging this change will absolutely require the minimum supported version for the add-on to be raised to Bitbucket Server 5.x. 4.x versions do not have the PostRepositoryHook types, and this change will fail to start when deployed to them.

One last thing I'll note. In the pom.xml for this add-on, I see it still using AMPS 6.2.9. That version is not actually compatible with Bitbucket Server 5.x. The only reason it's not causing pain is this plugin has no integration tests. Regardless, I would recommend updating AMPS to 6.3.3.

impl.onReceive(context, refChanges, null);
}
this.authCtx, this.permissions, this.repoService, this.properties);
impl.preUpdateImpl(context, request);
Copy link

Choose a reason for hiding this comment

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

This indenting seems off /nit


@Override
public RepositoryHookResult preUpdate(PreRepositoryHookContext context, PullRequestMergeHookRequest request) {
// TODO Auto-generated method stub
Copy link

Choose a reason for hiding this comment

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

This, and the blank line after it, should probably be removed?

@@ -99,6 +93,10 @@ public ProcessBuilder createProcessBuilder(
log.error("Can't get user email address. getEmailAddress() call returns null");
}
env.put("STASH_REPO_NAME", repo.getName());

if (request.getScmHookDetails().isPresent()) {
Copy link

Choose a reason for hiding this comment

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

I'd write this as:

request.getScmHookDetails().ifPresent(details -> env.putAll(details.getEnvironment()));

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. Fancy Java is new to me :)

while ((data = input.read()) >= 0) {
if (count >= 65000) {
if (!trimmed) {
builder.
Copy link

Choose a reason for hiding this comment

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

builder.append("\n")
        .append("Hook response exceeds 65K length limit.\n")
        .append("Further output will be trimmed\n");
trimmed = true;

Maybe?

int result = process.waitFor();

if (result == 0) {
return RepositoryHookResult.accepted();
Copy link

Choose a reason for hiding this comment

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

Indenting /nit


if (result == 0) {
return RepositoryHookResult.accepted();
} else {
Copy link

Choose a reason for hiding this comment

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

This else is unnecessary. The if above it returns, so you could just write:

if (result == 0) {
    return RepositoryHookResult.accepted();
}
return RepositoryHookResult.rejected(summaryMessage, builder.toString());

String rawDetailedMsg = errWriter.toString();
String prePrefix = "<pre style=\"overflow: auto; white-space: nowrap;\">";
String preSuffix = "</pre>";
String detailedMsg = prePrefix + rawDetailedMsg.replaceAll("(\r\n|\n)", "<br/>").replaceAll(" ", " ") + preSuffix;
Copy link

Choose a reason for hiding this comment

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

Does dropping this detailedMsg formatting affect how this displays in the UI when the check fails? Is that desirable? (Or perhaps the new hook SPI doesn't allow for the formatting to work correctly, anymore? I could believe that.)

Copy link

Choose a reason for hiding this comment

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

(Nevermind; I see from #53 that dropping this is a good thing to do. It sounds like @seletskiy has already made the matching change to his version of the plugin.)

@itay
Copy link
Contributor Author

itay commented Aug 18, 2017

@bturner thanks for the feedback.

@seletskiy I will correct these and open a new PR against your repo!

@fncmedia
Copy link

@itay I sounds like your fix could solve our current problems. Have you already a timing for finishing your pr?

@seletskiy
Copy link
Member

@itay: ping.

@joerg
Copy link

joerg commented Dec 11, 2017

Hi,
I just stumbled upon this because our pre-recieve hooks are not working any more. Seems the missing GIT_QUARANTINE_PATH is the cause. Any chance to get this fixed?

@chroto
Copy link

chroto commented Jan 20, 2018

We also are struggling with this and would like to see it merged. Anything I can help with?

@chroto
Copy link

chroto commented Jan 20, 2018

@itay @seletskiy would it be in bad form to open this PR on https://github.com/seletskiy/atlassian-external-hooks myself ?

@itay
Copy link
Contributor Author

itay commented Jan 20, 2018

Please go ahead :) No reason to block this on my unavailability!

@DrVanScott
Copy link

I added this PR on seletskiy's some days ago. Hope i did it the right way... seletskiy#3

@seletskiy
Copy link
Member

seletskiy commented Jan 31, 2018 via email

@fncmedia
Copy link

@seletskiy can you make an estimate when you would update your plugin?

@seletskiy seletskiy merged commit 15e8290 into reconquest:master Mar 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants