[PATCH] Display warning when flagging VCS packages

Lukas Fleischer lfleischer at archlinux.org
Sat May 25 17:07:33 UTC 2019


VCS packages should not be flagged out-of-date when the package version
does not match the most recent commit.

Implements FS#62733.

Signed-off-by: Lukas Fleischer <lfleischer at archlinux.org>
---
 web/html/css/aurweb.css      |  4 ++++
 web/html/pkgflag.php         |  5 +++++
 web/lib/pkgbasefuncs.inc.php | 21 +++++++++++++++++++++
 3 files changed, 30 insertions(+)

diff --git a/web/html/css/aurweb.css b/web/html/css/aurweb.css
index ef37bf5..81bf9ab 100644
--- a/web/html/css/aurweb.css
+++ b/web/html/css/aurweb.css
@@ -195,3 +195,7 @@ label.confirmation,
 .comments .more {
 	font-weight: normal;
 }
+
+.error {
+	color: red;
+}
diff --git a/web/html/pkgflag.php b/web/html/pkgflag.php
index 61346b9..2fba6bd 100644
--- a/web/html/pkgflag.php
+++ b/web/html/pkgflag.php
@@ -50,6 +50,11 @@ if (has_credential(CRED_PKGBASE_FLAG)): ?>
 		<li><?= htmlspecialchars($pkgname) ?></li>
 		<?php endforeach; ?>
 	</ul>
+	<?php if (pkgbase_is_vcs($base_id)): ?>
+	<p class="error">
+		This is a VCS package. Please do <strong>not</strong> flag this package out-of-date when the package version in the AUR does not match the most recent commit.
+	</p>
+	<?php endif; ?>
 	<p>
 		<?= __('Please do %snot%s use this form to report bugs. Use the package comments instead.',
 			'<strong>', '</strong>'); ?>
diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php
index 1df21a2..a492589 100644
--- a/web/lib/pkgbasefuncs.inc.php
+++ b/web/lib/pkgbasefuncs.inc.php
@@ -367,6 +367,27 @@ function pkgbase_get_pkgnames($base_id) {
 	return $result->fetchAll(PDO::FETCH_COLUMN, 0);
 }
 
+/**
+ * Determine whether a package base is (or contains a) VCS package
+ *
+ * @param int $base_id The ID of the package base
+ *
+ * @return bool True if the package base is/contains a VCS package
+ */
+function pkgbase_is_vcs($base_id) {
+	$suffixes = array("-cvs", "-svn", "-git", "-hg", "-bzr", "-darcs");
+	$haystack = pkgbase_get_pkgnames($base_id);
+	array_push($haystack, pkgbase_name_from_id($base_id));
+	foreach ($haystack as $pkgname) {
+		foreach ($suffixes as $suffix) {
+			if (substr_compare($pkgname, $suffix, -strlen($suffix)) === 0) {
+				return true;
+			}
+		}
+	}
+	return false;
+}
+
 /**
  * Delete all packages belonging to a package base
  *
-- 
2.21.0


More information about the aur-dev mailing list