From c601ef81b76d2c67330c25f93912fd1cafa04d9a Mon Sep 17 00:00:00 2001 From: Nate-Wessel Date: Fri, 13 Dec 2024 21:15:18 +0000 Subject: [PATCH 1/3] add route for checking git version of currend HEAD --- backend/app/routes.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/app/routes.py b/backend/app/routes.py index 1ef1e90..3f087a4 100644 --- a/backend/app/routes.py +++ b/backend/app/routes.py @@ -1,4 +1,5 @@ import json, re +from subprocess import check_output from datetime import datetime from flask import jsonify, request from app import app @@ -25,6 +26,13 @@ def index(): ] }) +@app.route('/version') +def getGitHash(): + """Return the Git hash of the application""" + return jsonify({ + 'git-hash': check_output(['git', 'rev-parse', 'HEAD']).decode('ascii').strip() + }) + # test URL /closest-node/-79.3400/43.6610 @app.route('/nodes-within///', methods=['GET']) def closest_node(meters, longitude, latitude): From 939415bb7b16a3d9a93625047dbb15c1a4920662 Mon Sep 17 00:00:00 2001 From: Nate-Wessel Date: Fri, 13 Dec 2024 21:26:00 +0000 Subject: [PATCH 2/3] refactor to separate function --- backend/app/getGitHash.py | 4 ++++ backend/app/routes.py | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 backend/app/getGitHash.py diff --git a/backend/app/getGitHash.py b/backend/app/getGitHash.py new file mode 100644 index 0000000..f3063fa --- /dev/null +++ b/backend/app/getGitHash.py @@ -0,0 +1,4 @@ +from subprocess import check_output + +def getGitHash(): + return check_output(['git', 'rev-parse', 'HEAD']).decode('ascii').strip() diff --git a/backend/app/routes.py b/backend/app/routes.py index 3f087a4..64d35af 100644 --- a/backend/app/routes.py +++ b/backend/app/routes.py @@ -1,5 +1,4 @@ import json, re -from subprocess import check_output from datetime import datetime from flask import jsonify, request from app import app @@ -9,7 +8,7 @@ from app.get_travel_time import get_travel_time from app.get_here_links import get_here_links from app.get_centreline_links import get_centreline_links - +from app.getGitHash import getGitHash @app.route('/') def index(): """Provide basic documentation about the available resources. @@ -27,10 +26,10 @@ def index(): }) @app.route('/version') -def getGitHash(): +def version(): """Return the Git hash of the application""" return jsonify({ - 'git-hash': check_output(['git', 'rev-parse', 'HEAD']).decode('ascii').strip() + 'git-hash': getGitHash() }) # test URL /closest-node/-79.3400/43.6610 From 209426d5181890bec19634cf3276cccdb927d5ba Mon Sep 17 00:00:00 2001 From: Nate-Wessel Date: Fri, 13 Dec 2024 21:27:53 +0000 Subject: [PATCH 3/3] specify hash is of current head node --- backend/app/routes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/app/routes.py b/backend/app/routes.py index 64d35af..2c9a4b4 100644 --- a/backend/app/routes.py +++ b/backend/app/routes.py @@ -27,9 +27,9 @@ def index(): @app.route('/version') def version(): - """Return the Git hash of the application""" + """Return the Git hash of the current application HEAD""" return jsonify({ - 'git-hash': getGitHash() + 'git-HEAD': getGitHash() }) # test URL /closest-node/-79.3400/43.6610