From 428ae1c2fed720c34ba9f8e06c0e90e3ec2af9c2 Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Thu, 22 Mar 2018 08:22:56 +0100
Subject: [PATCH] plumed patch -e accepts a close match

When doing plumed patch -e gromacs2016.5 a match with e.g. gromacs2016.4
will be accepted (and issue a WARNING). Useful for automatized patching
procedures.

For instance, in gromacs-plumed package of MacPorts it won't be necessary
to synchronize the Portfile with the exact plumed version.
---
 patches/patch.sh | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/patches/patch.sh b/patches/patch.sh
index 296f90dcf..8d1a6037a 100755
--- a/patches/patch.sh
+++ b/patches/patch.sh
@@ -182,6 +182,25 @@ then
   done
 fi
 
+if [[ "$action" == patch || "$action" == revert ]]
+then
+  found=no
+  for engine_try in $mdlist ; do
+    if [[ "$engine" == "$engine_try" ]] ; then
+      found=yes
+    fi
+  done
+  if [[ "$found" == no ]] ; then
+    echo "WARNING: engine $engine not found, I will search for a close match"
+    for engine_try in $mdlist ; do
+      if [[ "${engine%.*}" == "${engine_try%.*}" ]] ; then
+        echo "WARNING: found $engine_try"
+        engine="$engine_try"
+      fi
+    done
+  fi
+fi
+
 if [ -z "$diff" ]
 then
   diff="$PLUMED_ROOT/patches/${engine}.diff"
-- 
GitLab