10000 Show shortened SHA1 in user interface hyperlink by MarkEWaite · Pull Request #128 · jenkinsci/github-plugin · GitHub
[go: up one dir, main page]

Skip to content

Show shortened SHA1 in user interface hyperlink #128

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

Conversation

MarkEWaite
Copy link
Contributor
@MarkEWaite MarkEWaite commented Jul 6, 2016

Attempt to keep the code DRY.

Please consider this mostly a solicitation for feedback, rather than a final submission that is ready to merge into the master branch.

Is this what you were envisioning by using Hamcrest instead of the style used in the existing test?


This change is Reviewable

text.wrapBy("", " (<a href='" + url.commitId(cs.getId()) + "'>commit: " + cs.getId() + "</a>)");
8000 final String id = cs.getId();
text.wrapBy("", " (<a href='" + url.commitId(id)
+ "'>commit: " + id.substring(0, Math.min(id.length(), 7)) + "</a>)");
Copy link
Member

Choose a reason for hiding this comment

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

@lanwen maybe string format?

Copy link
Member

Choose a reason for hiding this comment

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

yep!

@lanwen
Copy link
Member
lanwen commented Jul 8, 2016

👍 please add string formatting and i'll be ready to merge it

+ startHREF
+ innerText
+ endHREF
+ ")");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lanwen was this the type of formatting you were envisioning? It seems to clarify the subcomponents of the markup, but I'm not sure that is what you were expecting?

@MarkEWaite MarkEWaite force-pushed the JENKINS-36445-reduce-length-of-sha1-hamcrest branch from 20b0cdf to 0ba15ec Compare July 8, 2016 15:54
text.wrapBy("", " (<a href='" + url.commitId(id)
+ "'>commit: " + id.substring(0, Math.min(id.length(), 7)) + "</a>)");
final String innerText = "commit: " + id.substring(0, Math.min(id.length(), 7));
text.wrapBy("", format(" (<a href='%s'>%s</a>)", url.commitId(id), innerText));
Copy link
Contributor Author
@MarkEWaite MarkEWaite Jul 8, 2016

Choose a reason for hiding this comment

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

Is this closer to the style you wanted in the code?

If so, then (if you don't mind) I'd like to rebase this series of commits into a single commit with a better comment, then force push it into this pull request. Would that be ok with you?

Copy link
Member

Choose a reason for hiding this comment

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

No, String.format() that IDEA would suggest to replace automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, I'm not an IDEA user. Can you provide your preferred change to that line?

@MarkEWaite MarkEWaite force-pushed the JENKINS-36445-reduce-length-of-sha1-hamcrest branch from 0ba15ec to 2f70571 Compare July 9, 2016 12:31
@MarkEWaite MarkEWaite changed the title Add annotator prototype test with Hamc 8000 rest assertions Show shortened SHA1 in user interface hyperlink Jul 9, 2016
@MarkEWaite MarkEWaite force-pushed the JENKINS-36445-reduce-length-of-sha1-hamcrest branch 2 times, most recently from 28e5dbe to 87d8385 Compare July 9, 2016 14:47
@@ -42,7 +44,9 @@ void annotate(final GithubUrl url, final MarkupText text, final Entry change) {

if (change instanceof GitChangeSet) {
GitChangeSet cs = (GitChangeSet) change;
text.wrapBy("", " (<a href='" + url.commitId(cs.getId()) + "'>commit: " + cs.getId() + "</a>)");
final String id = cs.getId();
final String innerText = "commit: " + id.substring(0, Math.min(id.length(), 7));
Copy link
Member
@lanwen lanwen Jul 9, 2016

Choose a reason for hiding this comment

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

one more thing please: just inline it to string pattern to avoid string concatenation with "+"

Most git repository browsing systems (bitbucket, cgit, github, gitweb)
display a short form of the SHA1 (commonly the first 7 characters) with
a clickable hyperlink that will take them to a page that includes the
full SHA1.

This change reduces the visible SHA1 text in the list of changes to the
first 7 characters of the SHA1, consistent with those other repository
browsers. It also adds assertions that the expected format is used and
simplifies the existing annotator tests.
@MarkEWaite MarkEWaite force-pushed the JENKINS-36445-reduce-length-of-sha1-hamcrest branch from 87d8385 to a8c40b4 Compare July 10, 2016 01:18
@lanwen
Copy link
Member
lanwen commented Jul 11, 2016

Perfectly!

@lanwen lanwen merged commit ca75bde into jenkinsci:master Jul 11, 2016
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.

3 participants
0