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

+ [JENKINS-30176] Repository browser VisualSVN added #163

Merged
merged 16 commits into from
Apr 20, 2018

Conversation

arnosthavelka
Copy link
Contributor

[JENKINS-30176] Repository browser VisualSVN added

@arnosthavelka
Copy link
Contributor Author

arnosthavelka commented Jun 16, 2016

Ad build failure) Well, external repository https://svn.jenkins-ci.org/ is not available. No test error is related to my change (there's no test on browser provider implementation).

@arnosthavelka
Copy link
Contributor Author

Fixed just by merging to the latest sources (after version 2.6).

@arnosthavelka
Copy link
Contributor Author

I am wondering why is it still opened (waiting)? And not accepted or rejected. I am forced to use my own plugin's build. I would like to handle SVN plugin as any other in Plugin Manager.

@yultide
Copy link

yultide commented Dec 16, 2016

@jglick @recena Can someone merge this? I want to use VisualSVN server with Jenkins without a custom plugin build

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

Javadoc does not seem to be finalized according to DOCUMENT ME! comments. There are also some minor glitches in the code

/*
* The MIT License
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Daniel Dyer
Copy link
Member

Choose a reason for hiding this comment

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

Likely the license header is wrong

// https://issues.jenkins-ci.org/browse/JENKINS-30176
public class VisualSVN extends SubversionRepositoryBrowser {

private static final Logger LOGGER = Logger.getLogger(VisualSVN.class.getName());
Copy link
Member

Choose a reason for hiding this comment

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

formatting

@Extension
public static class DescriptorImpl extends Descriptor<RepositoryBrowser<?>> {
public String getDisplayName() {
return "VisualSVN";
Copy link
Member

Choose a reason for hiding this comment

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

Good practice: Keep the name localizable. https://wiki.jenkins-ci.org/display/JENKINS/Internationalization

* It may contain a query parameter like <tt>?root=foobar</tt>, so relative
* URL construction needs to be done with care.</p>
*/
public final String url;
Copy link
Member

Choose a reason for hiding this comment

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

Better to use private field and getter. Otherwise you will be never able to change the data structure without breaking compatibility

this.url = validateUrl(url);
}

private String validateUrl(URL url) {
Copy link
Member

Choose a reason for hiding this comment

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

Confusing method name. Nothing is validated here

<f:entry title="URL" field="url">
<f:textbox />
</f:entry>
</j:jelly>
Copy link
Member

Choose a reason for hiding this comment

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

Good practice: add line breaks to the last file lines

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, there's a lot of comments :-). I just copied some other plugin (comments, maybe XML additional line, etc.) and modified it for VisualSVN.

I wil try to fix it according comments above. It should be simple.

// https://demo-server.visualsvn.com/!/#tortoisesvn/commit/r27333/head/trunk/src/Utils/MiscUI/SciEdit.cpp
int r = path.getLogEntry().getRevision();
String value = String.format("%s/commit/r%d/head%s", url, r, path.getValue());
LOGGER.fine("DiffLink URL: " + value);
Copy link
Member

Choose a reason for hiding this comment

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

Better to use formatter to avoid non-required string concatenations

@Override public URL getFileLink(Path path) throws IOException {
// https://demo-server.visualsvn.com/!/#tortoisesvn/view/head/svnrobots.txt
String value = String.format("%s/view/head%s", url, path.getValue());
LOGGER.fine("FileLink URL: " + value);
Copy link
Member

Choose a reason for hiding this comment

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

same

throws IOException {
// https://demo-server.visualsvn.com/!/#tortoisesvn/commit/r27333
String value = String.format("%s/commit/r%d", url, changeSet.getRevision());
LOGGER.fine("ChangeSetLink URL: " + value);
Copy link
Member

Choose a reason for hiding this comment

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

same

* {@link RepositoryBrowser} for Subversion.
*
* @author Arnost Havelka
* @since 2.5.8
Copy link
Member

Choose a reason for hiding this comment

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

Please replace the since value by TODO. It may not be merged into the specified version

@arnosthavelka
Copy link
Contributor Author

I tried to fix all commets, but I am not sure about source formatting (where is it defined) and formatter (I used String.format()).

Is it sufficient? If not, can you provide more details/hints?

@oleg-nenashev
Copy link
Member

@arnosthavelka

So there are two approaches, which are good from the performance PoV. See the examples below.

Approach 1

if (LOGGER.isLoggable(Level.FINE)) {
    String value = String.format("%s/commit/r%d/head%s", url, r, path.getValue());
    LOGGER.fine("DiffLink URL: " + value);
}

Approach 2

LOGGER.log(Level.FINE, "DiffLink URL: {0}/commit/r{1}/head{2}", new Object[] {url, r, path.getValue()});

@arnosthavelka
Copy link
Contributor Author

LOGGER is fixed --> I was focused on fomatting of the value itself, not the logging the value.

@yultide
Copy link

yultide commented Jan 18, 2017

@oleg-nenashev any updates on when the merge will happen?

@ghost
Copy link

ghost commented Jun 14, 2017

Just making some noise: any news on an integration date?

@oleg-nenashev
Copy link
Member

@yultide @Bebef The plugin has no maintainer. @recena is inactive, and there is a plan to mark the plugin for adoption. See https://wiki.jenkins-ci.org/display/JENKINS/Adopt+a+Plugin for more info.

The only thing I can do here is to review the PR after the last changes

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

The code will probably work, but the formatting is still messed up.

*/
public class VisualSVN extends SubversionRepositoryBrowser {

private static final Logger LOGGER = Logger.getLogger(VisualSVN.class.getName());
Copy link
Member

Choose a reason for hiding this comment

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

tabs vs. spaces

throw new MalformedURLException(Messages.SubversionSCM_doCheckRemote_invalidUrl());
}
String value = url.toString();
if (value == null || value.equals("")) {
Copy link
Member

Choose a reason for hiding this comment

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

StringUtils.isBlank(). Otherwise you will be accepting blank strings like " "

* @throws MalformedURLException when URL is not valid (empty)
*/
@DataBoundConstructor
public VisualSVN(URL url) throws MalformedURLException {
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if Stapler handles URLs reliably. CC @daniel-beck and @vivek

Copy link
Member

Choose a reason for hiding this comment

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

Should make the parameter type be String, to match that of the getter. Otherwise this will not be compatible with Pipeline’s Snippet Generator, for example, and might cause mayhem in JEP-201 etc.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it's better to fix it before merge

// https://demo-server.visualsvn.com/!/#tortoisesvn/view/head/svnrobots.txt
String value = String.format("%s/view/head%s", url, path.getValue());
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("FileLink URL: " + value);
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if it is helpful even at the FINE level. Maybe DEBUG?

// https://demo-server.visualsvn.com/!/#tortoisesvn/commit/r27333
String value = String.format("%s/commit/r%d", url, changeSet.getRevision());
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("ChangeSetLink URL: " + value);
Copy link
Member

Choose a reason for hiding this comment

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

same

@@ -1,86 +1,88 @@
# The MIT License
#
# Copyright (c) 2004-2011, Sun Microsystems, Inc., Kohsuke Kawaguchi, Seiji Sogabe, Yahoo! Inc.
Copy link
Member

Choose a reason for hiding this comment

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

Formatting changes messed up the diff here

Copy link

Choose a reason for hiding this comment

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

Thanks for the update! 👍

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Probably good enough.

@@ -1,86 +1,88 @@
# The MIT License
#
# Copyright (c) 2004-2011, Sun Microsystems, Inc., Kohsuke Kawaguchi, Seiji Sogabe, Yahoo! Inc.
Copy link
Member

Choose a reason for hiding this comment

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


<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry title="URL" field="url">
Copy link
Member

Choose a reason for hiding this comment

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

You forget a getUrl method, so config round-trip does not work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, it's not clear to me. Where should I use getUrl method? I was not able to find any usage of it in other config.jelly files.
Please, can you be more specific or fix it? I just did "copy & past " on one browser (don't know which one now). The solution was working correctly as I know.

Copy link

Choose a reason for hiding this comment

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

@arnosthavelka I am not an expert but I think it might be something like here:

<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
  <f:entry title="URL" help="/plugin/WebSVN2/help-url.html">
   <f:textbox field="reposUrl" name="webSVN2.url" value="${browser.url}"/>
  </f:entry>
</j:jelly>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure whether the suggestion by queil is right answer My config.jelly has same content as for SVNWeb, ViewSVN, WebSVN. The other implementation have same <f:entry/> for "URL" content, but additional element <f:entry/> for "Repository".

Should I use this?
<f:entry title="URL" help="/plugin/VisualSVN/help-url.html">

@jglick Please, can you confirm it or clarify your claim?

Copy link

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

The advice from @queil is incorrect. The f:entry and empty f:textbox are fine; you just need to add a getUrl getter method to the bean. See Jenkins docs on form databinding. (You could reproduce your bug using one of the JenkinsRule.configRoundtrip overloads if you cared to.)

No help attribute is necessary: you are following the conventional location of help-url.html.

Copy link
Member

Choose a reason for hiding this comment

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

Resolved

@arnosthavelka
Copy link
Contributor Author

@oleg-nenashev Please, can you remove "merge-conflict" tag? It's already up-to-date.

@oleg-nenashev
Copy link
Member

removed the label, the PR still needs review feedback

@oleg-nenashev
Copy link
Member

@jenkinsci/code-reviewers


<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry title="URL" field="url">
Copy link
Member

Choose a reason for hiding this comment

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

The advice from @queil is incorrect. The f:entry and empty f:textbox are fine; you just need to add a getUrl getter method to the bean. See Jenkins docs on form databinding. (You could reproduce your bug using one of the JenkinsRule.configRoundtrip overloads if you cared to.)

No help attribute is necessary: you are following the conventional location of help-url.html.

@arnosthavelka
Copy link
Contributor Author

I just merged latest changes and added getter for URL property as adviced by @jglick. It's strange that almost none other class have such getter.

@jglick: Is it OK now?

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Still a mistake in databinding I think.

* @throws MalformedURLException when URL is not valid (empty)
*/
@DataBoundConstructor
public VisualSVN(URL url) throws MalformedURLException {
Copy link
Member

Choose a reason for hiding this comment

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

Should make the parameter type be String, to match that of the getter. Otherwise this will not be compatible with Pipeline’s Snippet Generator, for example, and might cause mayhem in JEP-201 etc.

@@ -90,4 +90,4 @@ CredentialsSVNAuthenticationProviderImpl.credentials_in_realm=Found credentials
CredentialsSVNAuthenticationProviderImpl.sole_credentials=Using sole credentials {0} in realm \u2018{1}\u2019
CredentialsSVNAuthenticationProviderImpl.missing_credentials=No credentials found for realm \u2018{0}\u2019 among \u2018{1}\u2019; falling back to {2}


SubversionSCM.browsers.VisualSVN=VisualSVN
Copy link
Member

Choose a reason for hiding this comment

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

Best to add a trailing newline.

Copy link
Contributor Author

@arnosthavelka arnosthavelka Feb 18, 2018

Choose a reason for hiding this comment

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

I just merged with latest changes and added trailing newline to the messages.properties file (as requested).

However I'm not sure about the request to change the param from URL to String. Almost every implementation (except Assembla) has it in the same way (as URL). Therefore I propose to do not change the parameter type, since I'm not able to verify the correctness of the change anymore. If it will be problem for Snippet Generator then someone will have to change it in all others implementations anyway.

Please, can we finish it now? We are discussing PR for 2 years now.

Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately it's what we have for barely maintained plugins.
I and @jglick spent some time on cleaning up the PR queue this summer, but there were other maintainers before.
@kuisathaverat was interested in taking ownership of the plugin tho

Copy link
Contributor

Choose a reason for hiding this comment

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

@arnosthavelka I made a PR with the suggested pending changes, merge it on your branch and I think that this PR is ready to merge

arnosthavelka#1

@arnosthavelka
Copy link
Contributor Author

@jglick Please, can you check my comment?

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

1 change is required in the constructor the rest looks good to me, would be great to finally merge it

* @throws MalformedURLException when URL is not valid (empty)
*/
@DataBoundConstructor
public VisualSVN(URL url) throws MalformedURLException {
Copy link
Member

Choose a reason for hiding this comment

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

Yes, it's better to fix it before merge


<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry title="URL" field="url">
Copy link
Member

Choose a reason for hiding this comment

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

Resolved

@@ -90,4 +90,4 @@ CredentialsSVNAuthenticationProviderImpl.credentials_in_realm=Found credentials
CredentialsSVNAuthenticationProviderImpl.sole_credentials=Using sole credentials {0} in realm \u2018{1}\u2019
CredentialsSVNAuthenticationProviderImpl.missing_credentials=No credentials found for realm \u2018{0}\u2019 among \u2018{1}\u2019; falling back to {2}


SubversionSCM.browsers.VisualSVN=VisualSVN
Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately it's what we have for barely maintained plugins.
I and @jglick spent some time on cleaning up the PR queue this summer, but there were other maintainers before.
@kuisathaverat was interested in taking ownership of the plugin tho

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

Let's ship it

@arnosthavelka
Copy link
Contributor Author

What's the status? To avoid merging additional changes :-).

@kuisathaverat
Copy link
Contributor

@arnosthavelka it is my fault, I think I have merged it

@kuisathaverat kuisathaverat merged commit 52b7a92 into jenkinsci:master Apr 20, 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.

6 participants