2 ##############################################################################
3 # Copyright (c) 2017 Luke Hinds <lhinds@redhat.com>, Red Hat
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
11 GERRITUSER="lukehinds"
12 REPO_DIR="/home/luke/repos/opnfv"
13 FORMATED_DIR=$(echo $REPO_DIR |sed 's./.\\/.g')
17 echo -e "A script to generate a patchset file to allow local anteater tests"
18 echo -e "in the same manner as OPNFV security audit gate checks.\n"
19 echo -e "Please insure GERRITUSER and REPO_DIR are set within the script\n"
20 echo -e "You will also need to pass the following arguments.\n"
21 echo -e "--project <project>\n"
22 echo -e "for example:"
23 echo -e "--project releng\n"
24 echo -e " * note that the project name has to be the same as the git"
25 echo -e " repository name for the project\n"
26 echo -e "--patch <patch_number>\n"
27 echo -e "for example:"
28 echo -e "--patch 39741\n"
29 echo -e " * note that the patchset can be retrieved from the URL,"
30 echo -e " e.g https://gerrit.opnfv.org/gerrit/#/c/39741/\n"
31 echo -e "The above would create the patch set as /tmp/patchset_39741\n"
32 echo -e "You will then be able to run anteater as follows:"
33 echo -e "$ anteater --project sandbox --patchset /tmp/patchset_39741"
40 echo "Usage: $0 [--project <project>] [--patch <patch_number>] [--help>]" 1>&2; exit 1;
46 "--project") set -- "$@" "-p" ;;
47 "--patch") set -- "$@" "-n" ;;
48 "--help") set -- "$@" "-h" ;;
54 while getopts ":p:n:h" arg; do
73 if [ -z "${p}" ] || [ -z "${n}" ]; then
77 ssh -p 29418 ${GERRITUSER}@gerrit.opnfv.org gerrit query \
78 --current-patch-set ${n} \
79 --files|grep file:|sed 's/file:\s\/COMMIT_MSG//;s/file://'| \
81 sed -e "s/^/${FORMATED_DIR}\/${p}\//"| tr -d " \t\r" \
84 echo -e "Patchset created as /tmp/patchset_${n}"
85 echo -e "You can now run: $ anteater --project ${p} --patchset /tmp/patchset_${n}"