From dd6efb9cee08786b0506475db72e22f1cd996f09 Mon Sep 17 00:00:00 2001 From: Christian W. Damus Date: Mon, 4 Jan 2016 11:59:47 -0500 Subject: [Releng] Dependency updater tool Ignore equivalent URL prefixes in detecting suspicious updates --- .../org.eclipse.papyrus.releng.tools/.classpath | 14 ++++---- .../.settings/org.eclipse.jdt.core.prefs | 6 ++-- .../META-INF/MANIFEST.MF | 2 +- .../internal/popup/actions/DependencyUpdater.java | 40 +++++++++++++++++----- 4 files changed, 42 insertions(+), 20 deletions(-) (limited to 'plugins/developer/org.eclipse.papyrus.releng.tools') diff --git a/plugins/developer/org.eclipse.papyrus.releng.tools/.classpath b/plugins/developer/org.eclipse.papyrus.releng.tools/.classpath index b1dabee3829..eca7bdba8f0 100644 --- a/plugins/developer/org.eclipse.papyrus.releng.tools/.classpath +++ b/plugins/developer/org.eclipse.papyrus.releng.tools/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/plugins/developer/org.eclipse.papyrus.releng.tools/.settings/org.eclipse.jdt.core.prefs b/plugins/developer/org.eclipse.papyrus.releng.tools/.settings/org.eclipse.jdt.core.prefs index 9ca8e68231b..62a08f4494d 100644 --- a/plugins/developer/org.eclipse.papyrus.releng.tools/.settings/org.eclipse.jdt.core.prefs +++ b/plugins/developer/org.eclipse.papyrus.releng.tools/.settings/org.eclipse.jdt.core.prefs @@ -1,10 +1,10 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 diff --git a/plugins/developer/org.eclipse.papyrus.releng.tools/META-INF/MANIFEST.MF b/plugins/developer/org.eclipse.papyrus.releng.tools/META-INF/MANIFEST.MF index 9b512415f9c..6f654e72da3 100644 --- a/plugins/developer/org.eclipse.papyrus.releng.tools/META-INF/MANIFEST.MF +++ b/plugins/developer/org.eclipse.papyrus.releng.tools/META-INF/MANIFEST.MF @@ -18,4 +18,4 @@ Bundle-Name: %Bundle-Name Bundle-ManifestVersion: 2 Bundle-Activator: org.eclipse.papyrus.releng.tools.internal.Activator Bundle-SymbolicName: org.eclipse.papyrus.releng.tools;singleton:=true -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/popup/actions/DependencyUpdater.java b/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/popup/actions/DependencyUpdater.java index 8cba78c8113..97a0a521f34 100644 --- a/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/popup/actions/DependencyUpdater.java +++ b/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/popup/actions/DependencyUpdater.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2015 Mia-Software, CEA LIST, Christian W. Damus, and others. + * Copyright (c) 2011, 2016 Mia-Software, CEA LIST, Christian W. Damus, and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,6 +10,7 @@ * Camille Letavernier (CEA LIST) - Generalize to support POMs * Christian W. Damus (CEA) - Add support for updating Oomph setup models * Christian W. Damus - Support updating of multiple selected files + * Christian W. Damus - Ignore equivalent URL prefixes in detecting suspicious updates * *******************************************************************************/ package org.eclipse.papyrus.releng.tools.internal.popup.actions; @@ -389,20 +390,26 @@ public abstract class DependencyUpdater { } private interface LocationUpdateStrategy { + Pattern URL_PREFIX_PATTERN = Pattern.compile("^(?:\\$\\{[^}]+\\}/|\\Qhttp://download.eclipse.org/\\E)"); //$NON-NLS-1$ + boolean shouldAutoUpdate(UpdateItem update, String oldLocation, String newLocation); String getUpdateConfirmationMessage(UpdateItem update, String oldLocation, String newLocation); - } - static class MilestoneLocationStrategy implements LocationUpdateStrategy { - private final Pattern typicalBuildTimestampPattern = Pattern.compile("[NISMR](?:-\\d+\\.\\d+(?:\\.\\d+)?(?:M|RC)\\d[abcd]-)?20\\d\\d[-0-9]+"); //$NON-NLS-1$ + default boolean hasRecognizedURLPrefix(String location) { + return URL_PREFIX_PATTERN.matcher(location).find(); + } - @Override - public boolean shouldAutoUpdate(UpdateItem update, String oldLocation, String newLocation) { - boolean result = true; // Optimistically assume sameness if we can't find any build timestamps + default String stripRecognizedURLPrefix(String location) { + Matcher m = URL_PREFIX_PATTERN.matcher(location); + return !m.find() ? location : location.substring(m.end()); + } - Matcher oldMatcher = typicalBuildTimestampPattern.matcher(oldLocation); - Matcher newMatcher = typicalBuildTimestampPattern.matcher(newLocation); + default boolean matchURLPattern(Pattern urlPattern, String oldLocation, String newLocation) { + boolean result = true; // Optimistically assume sameness if we can't find matching URL path segment structures + + Matcher oldMatcher = urlPattern.matcher(oldLocation); + Matcher newMatcher = urlPattern.matcher(newLocation); boolean foundOld = oldMatcher.find(); boolean foundNew = newMatcher.find(); @@ -413,11 +420,26 @@ public abstract class DependencyUpdater { // Compare prefixes String oldPrefix = oldLocation.substring(0, oldMatcher.start()); String newPrefix = newLocation.substring(0, newMatcher.start()); + if (hasRecognizedURLPrefix(oldPrefix) && hasRecognizedURLPrefix(newPrefix)) { + // Both have equivalent URL prefixes, so remove those for comparison + oldPrefix = stripRecognizedURLPrefix(oldPrefix); + newPrefix = stripRecognizedURLPrefix(newPrefix); + } + result = newPrefix.equals(oldPrefix); } return result; } + } + + static class MilestoneLocationStrategy implements LocationUpdateStrategy { + private final Pattern typicalBuildTimestampPattern = Pattern.compile("[NISMR](?:-\\d+\\.\\d+(?:\\.\\d+)?(?:M|RC)\\d[abcd]-)?20\\d\\d[-0-9]+"); //$NON-NLS-1$ + + @Override + public boolean shouldAutoUpdate(UpdateItem update, String oldLocation, String newLocation) { + return matchURLPattern(typicalBuildTimestampPattern, oldLocation, newLocation); + } @Override public String getUpdateConfirmationMessage(UpdateItem update, String oldLocation, String newLocation) { -- cgit v1.2.3