[X2Go-Commits] [maintenancescripts] 05/08: git/hooks/x2go-post-receive-close-bugs: backport changes from x2go-post-receive-tag-pending.

git-admin at x2go.org git-admin at x2go.org
Thu Mar 5 19:23:41 CET 2020


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository maintenancescripts.

commit e8ccbbceb88a6b31baf021eac3e429aa2eaf36d8
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Thu Mar 5 17:44:59 2020 +0100

    git/hooks/x2go-post-receive-close-bugs: backport changes from x2go-post-receive-tag-pending.
    
    Both scripts should now be synced up when it comes to the common parts.
---
 git/hooks/x2go-post-receive-close-bugs | 116 ++++++++++++++++++++++++---------
 1 file changed, 85 insertions(+), 31 deletions(-)

diff --git a/git/hooks/x2go-post-receive-close-bugs b/git/hooks/x2go-post-receive-close-bugs
index afd3f32..d92a119 100755
--- a/git/hooks/x2go-post-receive-close-bugs
+++ b/git/hooks/x2go-post-receive-close-bugs
@@ -1,8 +1,9 @@
 #! /bin/bash
 #
-# Copyright (c) 2009 Adeodato Simó (dato at net.com.org.es)
-# Copyright (c) 2013 Mike Gabriel (mike.gabriel at das-netzwerkteam.de)
-# Copyright (c) 2015 Mihai Moldovan (ionic at ionic.de)
+# Copyright © 2009 Adeodato Simó (dato at net.com.org.es)
+# Copyright © 2013 Mike Gabriel (mike.gabriel at das-netzwerkteam.de)
+# Copyright © 2013-2015 Guillem Jover <guillem at debian.org>
+# Copyright © 2015-2020 Mihai Moldovan (ionic at ionic.de)
 #
 # This software may be used and distributed according to the terms
 # of the MIT License, incorporated herein by reference.
@@ -22,14 +23,55 @@
 set -e
 set -u
 
-BASEURL="http://code.x2go.org/gitweb?p=${GIT_REPO_NAME}"
+BASEURL="https://code.x2go.org/gitweb?p=${GIT_REPO_NAME}"
 
 PROJECT="${SHORT_GIT_REPO_NAME}"
 
+SENDMAIL="/usr/sbin/sendmail -oi -t"
+
 tempdir="$(mktemp -d)"
 trap "rm -rf \"${tempdir}\"" EXIT
 
-function send_mail () { # send_mail bugno revno diff_file
+case "${DPKG_VERSION}" in
+1.16.*)
+  get_version()
+  {
+    local rev="${1}"
+    local c="${tempdir}/${rev}.changelog"
+
+    git show ${rev}:debian/changelog | sed -re 's/Fixes:/Closes:/i' > "${c}" 2>/dev/null
+    dpkg-parsechangelog -l"${c}" | sed -rne 's/^Version: *//pi'
+  }
+  get_bugs()
+  {
+    local rev="${1}"
+    local c="${tempdir}/${rev}.changelog"
+
+    git show ${rev}:debian/changelog | sed -re 's/Fixes:/Closes:/i' > "${c}" 2>/dev/null
+    dpkg-parsechangelog -l"${c}" | sed -rne 's/^Closes: *//pi'
+  }
+  ;;
+*)
+  get_version()
+  {
+    local rev="${1}"
+
+    git show ${rev}:debian/changelog 2>/dev/null \
+      | sed -re 's/Fixes:/Closes:/i' \
+      | dpkg-parsechangelog -l- -SVersion
+  }
+  get_bugs()
+  {
+    local rev="${1}"
+
+    git show ${rev}:debian/changelog 2>/dev/null \
+      | sed -re 's/Fixes:/Closes:/i' \
+      | dpkg-parsechangelog -l- -SCloses
+  }
+  ;;
+esac
+
+function send_mail () { # send_mail bugno fixed_in_version oldrevno newrevno diff_file
     local bug="${1}"
     local fixed_in_version="${2}"
     local oldrev="${3}"
@@ -57,14 +99,14 @@ thanks
 Hello,
 
 we are very hopeful that X2Go issue #${bug} reported by you
-has been resolved in the new release (${version}) of the
+has been resolved in the new release (${fixed_in_version}) of the
 X2Go source project »src:${PROJECT}«.
 
-You can view the complete changelog entry of src:${PROJECT} (${version})
+You can view the complete changelog entry of src:${PROJECT} (${fixed_in_version})
 below, and you can use the following link to view all the code changes
 between this and the last release of src:${PROJECT}.
 
-    ${BASEURL};a=commitdiff;h=$(git rev-parse ${newrev});hp=$(git rev-parse ${oldrev})
+    ${BASEURL};a=commitdiff;h=$(git rev-parse "${newrev}");hp=$(git rev-parse "${oldrev}")
 
 If you feel that the issue has not been resolved satisfyingly, feel
 free to reopen this bug report or submit a follow-up report with
@@ -78,12 +120,20 @@ X2Go Git Admin (on behalf of the sender of this mail)
 
 ---
 EOF
-    cat "${diff}") | /usr/sbin/sendmail -oi -t
+    cat "${diff}") | ${SENDMAIL}
 }
 
-## FIXME ## really go through this some time...
 while read oldrev newrev refname; do
-  if echo "${refname}" | egrep "refs/tags/" >/dev/null; then
+  # Only process tags.
+  # Bugs should only be getting closed as part of releases, which create new tags.
+  case "${refname}" in
+    ("refs/tags/"*)
+      :
+      ;;
+    (*)
+      continue
+      ;;
+  esac
     # find the last tag on this branch
     tag="${refname/refs\/tags\//}"
     oldrev="$(git rev-parse "${tag}")^"
@@ -92,27 +142,31 @@ while read oldrev newrev refname; do
     oldrev="$(git rev-parse "${oldrev}")"
     oldtag="$(git tag --contains "${oldrev}" | head -n1)"
 
-    c="${tempdir}/${newrev}.changelog"
-    d="${tempdir}/${newrev}.diff"
-
-    git show "${newrev}:debian/changelog" >"${c}" 2>/dev/null
-    cat "${c}" | sed 's/Fixes:/Closes:/i' | dpkg-parsechangelog -l- | sed 's/Closes:/Fixes:/i' |
-            sed -e 's/^Source: /X2Go Component: src:/' \
-                -e 's/-0~x2go[0-9]//' \
-                -e 's/-0$//' \
-                -e 's/^Distribution: unstable/Status: RELEASE/' \
-                -e 's/ unstable;/ RELEASED;/' \
-                -e 's/^Distribution: UNRELEASED/Status: PREVIEW/' \
-                -e 's/ UNRELEASED;/ PREVIEW;/' \
-            | egrep -v "^(Urgency:|Maintainer:).*" > "${d}"
-    #git diff "${oldrev}..${newrev}" -- "debian/changelog" >"${d}"
-    version="$(cat "${c}" | sed 's/Fixes:/Closes:/i' | dpkg-parsechangelog -l- | sed -rne 's/^Version: *//pi' -e 's/[0-9]+://' | cut -d"-" -f1)"
-    bugs="$(cat "${c}" | sed 's/Fixes:/Closes:/i' | dpkg-parsechangelog -l- | sed -rne 's/^Closes: *//pi')"
-    for bug in ${bugs}; do
-      info "Marking X2Go issue #${bug} as resolved/closed."
-      send_mail "${bug}" "${version}" "${oldrev}" "${newrev}" "${d}"
-    done
+  c="${tempdir}/${newrev}.changelog"
+  d="${tempdir}/${newrev}.diff"
+
+  # Check if this branch has a debian/changelog file to begin with and skip processing if there's
+  # none.
+  if ! git cat-file -e "${newrev}:debian/changelog" 2>'/dev/null'; then
+    continue
   fi
+
+  git show "${newrev}:debian/changelog" >"${c}" 2>'/dev/null'
+  cat "${c}" | sed 's/Fixes:/Closes:/i' | dpkg-parsechangelog -l- | sed 's/Closes:/Fixes:/i' |
+          sed -e 's/^Source: /X2Go Component: src:/' \
+              -e 's/-0~x2go[0-9]//' \
+              -e 's/-0$//' \
+              -e 's/^Distribution: unstable/Status: RELEASE/' \
+              -e 's/ unstable;/ RELEASED;/' \
+              -e 's/^Distribution: UNRELEASED/Status: PREVIEW/' \
+              -e 's/ UNRELEASED;/ PREVIEW;/' \
+          | grep -Ev "^(Urgency:|Maintainer:).*" > "${d}"
+  version="$(get_version "${rev}" | sed -re 's/[0-9]+://' | cut -d '-' -f '1')"
+  bugs="$(get_bugs "${rev}")"
+  for bug in ${bugs}; do
+    info "Marking X2Go issue #${bug} as resolved/closed."
+    send_mail "${bug}" "${version}" "${oldrev}" "${newrev}" "${d}"
+  done
 done
 
 # vi: et

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/maintenancescripts.git


More information about the x2go-commits mailing list