Skip to content

Commit a79dd8a

Browse files
committed
Add "description cut off" warning at end too
This has to be slightly more clever than the warning at the beginning to try and avoid weird markdown rendering (so it looks reasonably clean) but it isn't *too* horrible.
1 parent 0453c67 commit a79dd8a

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

push.pl

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ sub prompt_for_edit {
9696
my $fullUrl = "$githubBase/$proposedFile";
9797
my $shortTags = "-\tSee [\"Supported tags and respective \`Dockerfile\` links\" at $fullUrl]($fullUrl#supported-tags-and-respective-dockerfile-links)\n\n";
9898
my $tagsNote = "**Note:** the description for this image is longer than the Hub length limit of $lengthLimit, so the \"Supported tags\" list has been trimmed to compensate. See [docker/hub-beta-feedback#238](https://github.com/docker/hub-beta-feedback/issues/238) for more information.\n\n" . $shortTags;
99-
my $genericNote = "**Note:** the description for this image is longer than the Hub length limit of $lengthLimit, so has been trimmed. The full description can be found at [$fullUrl]($fullUrl). See [docker/hub-beta-feedback#238](https://github.com/docker/hub-beta-feedback/issues/238) for more information.\n\n";
99+
my $genericNote = "**Note:** the description for this image is longer than the Hub length limit of $lengthLimit, so has been trimmed. The full description can be found at [$fullUrl]($fullUrl). See [docker/hub-beta-feedback#238](https://github.com/docker/hub-beta-feedback/issues/238) for more information.";
100+
my $startingNote = $genericNote . "\n\n";
101+
my $endingNote = "\n\n...\n\n" . $genericNote;
100102

101103
$tagsNote = $shortTags if $alwaysShortTags;
102104

@@ -110,7 +112,19 @@ sub prompt_for_edit {
110112

111113
if (length($trimmedText) > $lengthLimit) {
112114
# ... if that doesn't do the trick, then do our older naïve description trimming
113-
$trimmedText = $genericNote . substr $proposedText, 0, ($lengthLimit - length($genericNote));
115+
$trimmedText = $startingNote . substr $proposedText, 0, ($lengthLimit - length($startingNote . $endingNote));
116+
117+
# adding the "ending note" (https://github.com/docker/hub-feedback/issues/2220) is a bit more complicated as we have to deal with cutting off markdown ~cleanly so it renders correctly
118+
# TODO deal with "```foo" appropriately (so we don't drop our note in the middle of a code block) - the Hub's current markdown rendering (2022-04-07) does not auto-close a dangling block like this, so this isn't urgent
119+
if ($trimmedText =~ m/\n$/) {
120+
# if we already end with a newline, we should be fine to just trim newlines and add our ending note
121+
$trimmedText =~ s/\n+$//;
122+
}
123+
else {
124+
# otherwise, we need to get a little bit more creative and trim back to the last fully blank line (which we can reasonably assume is safe thanks to our markdownfmt)
125+
$trimmedText =~ s/\n\n(.\n?)*$//;
126+
}
127+
$trimmedText .= $endingNote;
114128
}
115129

116130
$proposedText = $trimmedText;

0 commit comments

Comments
 (0)