Revert "Display a Docs-Preview link for each modified MD file"
This reverts commit 42d753031d3f8a7d1bfed9cecfda0bd0f082280f.
Reason for revert: Replaced by the work in skbug.com/11824
Original change's description:
> Display a Docs-Preview link for each modified MD file
>
> Bug: skia:11824
> Change-Id: I6bd557affca5ccf9f2936d86e2b0da168ceb2670
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/390577
> Commit-Queue: Ravi Mistry <rmistry@google.com>
> Reviewed-by: Joe Gregorio <jcgregorio@google.com>
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: skia:11824
Change-Id: Ia874ed6474fcae4698cd676dbdf208dbdefdedc4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399716
Reviewed-by: Ravi Mistry <rmistry@google.com>
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Commit-Queue: Ravi Mistry <rmistry@google.com>
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 6d9e6b2..75c4b70 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -37,9 +37,7 @@
AUTHORS_FILE_NAME = 'AUTHORS'
RELEASE_NOTES_FILE_NAME = 'RELEASE_NOTES.txt'
-DOCS_PREVIEW_URL_TMPL = 'https://skia.org/{path}?cl={issue}'
-DOCS_INDEX = '_index'
-
+DOCS_PREVIEW_URL = 'https://skia.org/?cl={issue}'
GOLD_TRYBOT_URL = 'https://gold.skia.org/search?issue='
SERVICE_ACCOUNT_SUFFIX = [
@@ -472,22 +470,17 @@
return []
results = []
+ at_least_one_docs_change = False
all_docs_changes = True
- docs_preview_links = []
for affected_file in change.AffectedFiles():
affected_file_path = affected_file.LocalPath()
file_path, _ = os.path.splitext(affected_file_path)
- top_level_dir = file_path.split(os.path.sep)[0]
- if 'site' == top_level_dir:
- site_path = os.path.sep.join(file_path.split(os.path.sep)[1:])
- # Strip DOCS_INDEX from the site_path to construct the docs_preview_link.
- if site_path.endswith(DOCS_INDEX):
- site_path = site_path[:-len(DOCS_INDEX)]
- docs_preview_link = DOCS_PREVIEW_URL_TMPL.format(
- path=site_path, issue=change.issue)
- docs_preview_links.append(docs_preview_link)
+ if 'site' == file_path.split(os.path.sep)[0]:
+ at_least_one_docs_change = True
else:
all_docs_changes = False
+ if at_least_one_docs_change and not all_docs_changes:
+ break
footers = change.GitFootersFromDescription()
description_changed = False
@@ -502,18 +495,18 @@
'This change has only doc changes. Automatically added '
'\'No-Try: true\' to the CL\'s description'))
- # Add all preview links that do not already exist in the description.
- if len(docs_preview_links) > 0:
- missing_preview_links = list(
- set(docs_preview_links) - set(footers.get('Docs-Preview', [])))
- if len(missing_preview_links) > 0:
- description_changed = True
- for missing_link in missing_preview_links:
- change.AddDescriptionFooter('Docs-Preview', missing_link)
- results.append(
- output_api.PresubmitNotifyResult(
- 'Automatically added link(s) to preview the docs changes to '
- 'the CL\'s description'))
+ # If there is at least one docs change then add preview link in the CL's
+ # description if it does not already exist there.
+ docs_preview_link = DOCS_PREVIEW_URL.format(issue=change.issue)
+ if (at_least_one_docs_change
+ and docs_preview_link not in footers.get('Docs-Preview', [])):
+ # Automatically add a link to where the docs can be previewed.
+ description_changed = True
+ change.AddDescriptionFooter('Docs-Preview', docs_preview_link)
+ results.append(
+ output_api.PresubmitNotifyResult(
+ 'Automatically added a link to preview the docs changes to the '
+ 'CL\'s description'))
# If the description has changed update it.
if description_changed: