Skip to content
Commits on Source (2)
#!/bin/sh
#
# Set up a clone of the security-tracker git repo
set -e
SRC=../../conf/pre-commit
HOOK=.git/hooks/pre-commit
install_pre_commit_hook() {
if [ -L "${HOOK}" ] && [ "$(readlink ${HOOK})" = "${SRC}" ]; then
echo "pre-commit hook already set up"
return
fi
if [ -e "${HOOK}" ] || [ -L "${HOOK}" ]; then
echo "Moving old pre-commit hook"
mv -f "${HOOK}" "${HOOK}.$(date '+%s')"
fi
echo "Installing pre-commit hook"
ln -s "${SRC}" "${HOOK}"
}
if [ "$(git rev-parse --show-cdup)" != '' ] || [ -d data/CVE/list ]; then
echo "This does not look like the git repo of the security tracker" 1>&2
exit 1
fi
install_pre_commit_hook
......@@ -45,14 +45,15 @@ def normalize_release(release):
class TrackerData(object):
DATA_URL = "https://security-tracker.debian.org/tracker/data/json"
GIT_URL = "https://salsa.debian.org/security-tracker-team/security-tracker.git"
CACHED_DATA_PATH = "~/.cache/debian_security_tracker.json"
CACHED_REVISION_PATH = "~/.cache/debian_security_tracker.rev"
GET_REVISION_COMMAND = \
"LC_ALL=C svn info svn://anonscm.debian.org/secure-testing|"\
"awk '/^Revision:/ { print $2 }'"
"LC_ALL=C git ls-remote %s | awk '/HEAD$/ { print $1 }'" % GIT_URL
DATA_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'data')
def __init__(self, update_cache=True):
self._latest_revision = None
self.cached_data_path = os.path.expanduser(self.CACHED_DATA_PATH)
self.cached_revision_path = os.path.expanduser(
self.CACHED_REVISION_PATH)
......@@ -62,14 +63,14 @@ class TrackerData(object):
@property
def latest_revision(self):
"""Return the current revision of the SVN repository"""
"""Return the current revision of the Git repository"""
# Return cached value if available
if hasattr(self, '_latest_revision'):
if self._latest_revision is not None:
return self._latest_revision
# Otherwise call out to svn to get the latest revision
# Otherwise call out to git to get the latest revision
output = subprocess.check_output(self.GET_REVISION_COMMAND,
shell=True)
self._latest_revision = int(output)
self._latest_revision = output.strip()
return self._latest_revision
def _cache_must_be_updated(self):
......@@ -78,7 +79,7 @@ class TrackerData(object):
self.cached_revision_path):
with open(self.cached_revision_path, 'r') as f:
try:
revision = int(f.readline())
revision = f.read()
except ValueError:
revision = None
if revision == self.latest_revision:
......
#!/bin/sh
set -e
if [ -z "${GIT_DIR}" ]; then
echo "GIT_DIR not set" 1>&2
exit 1
fi
exec 1>&2
make check-syntax