public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: repoman/cnf/repository/, repoman/man/, repoman/cnf/qa_data/, ...
@ 2018-07-14 15:48 Brian Dolbec
  0 siblings, 0 replies; only message in thread
From: Brian Dolbec @ 2018-07-14 15:48 UTC (permalink / raw
  To: gentoo-commits

commit:     f4faf6d7950150a3068f92a3f3615b884db897d6
Author:     Louis Sautier <sautier.louis <AT> gmail <DOT> com>
AuthorDate: Wed Jun 20 13:44:51 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul 14 15:44:08 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=f4faf6d7

repoman: add a check for unsorted KEYWORDS

 repoman/cnf/qa_data/qa_data.yaml                    |  1 +
 repoman/cnf/repository/qa_data.yaml                 |  1 +
 repoman/man/repoman.1                               |  3 +++
 .../pym/repoman/modules/scan/keywords/keywords.py   | 21 +++++++++++++++++++++
 4 files changed, 26 insertions(+)

diff --git a/repoman/cnf/qa_data/qa_data.yaml b/repoman/cnf/qa_data/qa_data.yaml
index 49ffdaf74..6aad56b8c 100644
--- a/repoman/cnf/qa_data/qa_data.yaml
+++ b/repoman/cnf/qa_data/qa_data.yaml
@@ -83,6 +83,7 @@ qahelp:
         missing: "Ebuilds that have a missing or empty KEYWORDS variable"
         stable: "Ebuilds that have been added directly with stable KEYWORDS"
         stupid: "Ebuilds that use KEYWORDS=-* instead of package.mask"
+        unsorted: "Ebuilds that contain KEYWORDS which are not sorted alphabetically."
     LICENSE:
         deprecated: "This ebuild is listing a deprecated license."
         invalid: "This ebuild is listing a license that doesnt exist in portages license/ dir."

diff --git a/repoman/cnf/repository/qa_data.yaml b/repoman/cnf/repository/qa_data.yaml
index 2e9e16b1d..c96ce46a9 100644
--- a/repoman/cnf/repository/qa_data.yaml
+++ b/repoman/cnf/repository/qa_data.yaml
@@ -67,6 +67,7 @@ qawarnings:
     - KEYWORDS.dropped
     - KEYWORDS.stupid
     - KEYWORDS.missing
+    - KEYWORDS.unsorted
     - LICENSE.deprecated
     - LICENSE.virtual
     - metadata.warning

diff --git a/repoman/man/repoman.1 b/repoman/man/repoman.1
index 01f37dd99..dea17c3b4 100644
--- a/repoman/man/repoman.1
+++ b/repoman/man/repoman.1
@@ -228,6 +228,9 @@ Ebuilds that have been added directly with stable KEYWORDS
 .B KEYWORDS.stupid
 Ebuilds that use KEYWORDS=-* instead of package.mask
 .TP
+.B KEYWORDS.unsorted
+Ebuilds that contain KEYWORDS which are not sorted alphabetically.
+.TP
 .B LICENSE.deprecated
 This ebuild is listing a deprecated license.
 .TP

diff --git a/repoman/pym/repoman/modules/scan/keywords/keywords.py b/repoman/pym/repoman/modules/scan/keywords/keywords.py
index 1e9623906..556f352ad 100644
--- a/repoman/pym/repoman/modules/scan/keywords/keywords.py
+++ b/repoman/pym/repoman/modules/scan/keywords/keywords.py
@@ -55,6 +55,8 @@ class KeywordChecks(ScanBase):
 
 		self._checkForMaskLikeKeywords(xpkg, y_ebuild, ebuild.keywords)
 
+		self._checkForUnsortedKeywords(ebuild, xpkg, y_ebuild)
+
 		self.slot_keywords[pkg.slot].update(ebuild.archs)
 		return False
 
@@ -133,6 +135,25 @@ class KeywordChecks(ScanBase):
 				self.qatracker.add_error("KEYWORDS.stupid",
 					"%s/%s.ebuild" % (xpkg, y_ebuild))
 
+	def _checkForUnsortedKeywords(self, ebuild, xpkg, y_ebuild):
+		'''Ebuilds that contain KEYWORDS
+		which are not sorted alphabetically.'''
+		def sort_keywords(kw):
+			# Split keywords containing hyphens. The part after
+			# the hyphen should be treated as the primary key.
+			# This is consistent with ekeyword.
+			parts = list(reversed(kw.lstrip("~-").split("-", 1)))
+			# Hack to make sure that keywords
+			# without hyphens are sorted first
+			if len(parts) == 1:
+				parts.insert(0, "")
+			return parts
+		sorted_keywords = sorted(ebuild.keywords, key=sort_keywords)
+		if sorted_keywords != ebuild.keywords:
+			self.qatracker.add_error("KEYWORDS.unsorted",
+				"%s/%s.ebuild contains unsorted keywords" %
+				(xpkg, y_ebuild))
+
 	@property
 	def runInPkgs(self):
 		'''Package level scans'''


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-07-14 15:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-14 15:48 [gentoo-commits] proj/portage:master commit in: repoman/cnf/repository/, repoman/man/, repoman/cnf/qa_data/, Brian Dolbec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox