[Secure-testing-commits] [Git][security-tracker-team/security-tracker][master] 2 commits: TrackerData: use git in instead of svn
Salvatore Bonaccorso
carnil at debian.org
Fri Dec 29 19:44:38 UTC 2017
Salvatore Bonaccorso pushed to branch master at Debian Security Tracker / security-tracker
Commits:
6ab7f10f by Salvatore Bonaccorso at 2017-12-29T19:17:00+00:00
TrackerData: use git in instead of svn
Use git-ls-remote instead of svn-info to determine the head revision.
v2: Adjust GIT_URL to the security-tracker.git repository
git-svn-id: svn+ssh://svn.debian.org/svn/secure-testing@59027 e39458fd-73e7-0310-bf30-c45bca0a0e42
- - - - -
01950495 by Salvatore Bonaccorso at 2017-12-29T19:17:02+00:00
Add pre-commit hook to check syntax
git-svn-id: svn+ssh://svn.debian.org/svn/secure-testing@59028 e39458fd-73e7-0310-bf30-c45bca0a0e42
- - - - -
3 changed files:
- + bin/setup-repo
- bin/tracker_data.py
- + conf/pre-commit
Changes:
=====================================
bin/setup-repo
=====================================
--- /dev/null
+++ b/bin/setup-repo
@@ -0,0 +1,31 @@
+#!/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
=====================================
bin/tracker_data.py
=====================================
--- a/bin/tracker_data.py
+++ b/bin/tracker_data.py
@@ -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:
=====================================
conf/pre-commit
=====================================
--- /dev/null
+++ b/conf/pre-commit
@@ -0,0 +1,12 @@
+#!/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
View it on GitLab: https://salsa.debian.org/security-tracker-team/security-tracker/compare/bb601da51397343ca4552f9d0fb18d16ab3abc9e...01950495e1cf950ed86b2f7ea4b5512ed243af23
---
View it on GitLab: https://salsa.debian.org/security-tracker-team/security-tracker/compare/bb601da51397343ca4552f9d0fb18d16ab3abc9e...01950495e1cf950ed86b2f7ea4b5512ed243af23
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/secure-testing-commits/attachments/20171229/6ae2783c/attachment-0001.html>
More information about the Secure-testing-commits
mailing list