From 90b6e858c3608fb389f0818771e0a0168215cb3f Mon Sep 17 00:00:00 2001 From: galperti <cristian.galperti@epfl.ch> Date: Fri, 22 Jan 2021 16:15:56 +0100 Subject: [PATCH] writegitinfo checks for clean working copy --- build/simulink_codegen/writegitinfoheader.m | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/build/simulink_codegen/writegitinfoheader.m b/build/simulink_codegen/writegitinfoheader.m index 9dc392c..8286682 100644 --- a/build/simulink_codegen/writegitinfoheader.m +++ b/build/simulink_codegen/writegitinfoheader.m @@ -2,6 +2,22 @@ function writegitinfoheader() % max description length maxdesclen=1024; + % Git checks first + + % 1) check repo cleanlyness + % TODO: check that the output of 'git status -procelain' is empty + [~,result] = system('git status --porcelain'); + if ~isempty(result) + error('the working copy is not clean, please commit changes first.'); + end + + % 2) check local and remote hash are matching (in synch working copy) + [~,localhash] = system('git rev-parse @'); + [~,remotehash] = system('git rev-parse @{u}'); + if ~strcmp(localhash, remotehash) + error('the working copy is not in sync with its origin, please push first.'); + end + % first we get TCV current shot number, to be used for tagging mdsconnect('tcvdata'); curshot=mdsvalue('current_shot("tcv_shot")'); -- GitLab