Skip to content
Snippets Groups Projects
Commit 0a2fa459 authored by Cristian Galperti's avatar Cristian Galperti
Browse files

writegitinfoheader corrected with usable options

- empty option corrected
- strict option added
parent cdb380c9
No related branches found
No related tags found
No related merge requests found
function writegitinfoheader(empty)
% Performs rtccode git tagging and
% code version string .h generation
%
% input arguments:
% varargin{1}: boolean, if true no git tagging will be performed
% and an empty .h code ver string will be
% generated. If false (default) git tagging
% will be attemped
% varargin{2}: boolean, if true (default) git working copy cleanlyness
% and remote sync will be checked. If false
% it will be checked but only warnings will
% be issued in case of violation.
function writegitinfoheader(varargin)
% max code description string length
maxdesclen=1024;
if nargin==0
empty=false;
strict=true;
end
if nargin==1
empty=varargin{1};
strict=true;
end
if nargin==2
empty=varargin{1};
strict=varargin{2};
end
if empty==false
% scd expcode info retrieval
try
......@@ -19,14 +45,22 @@ function writegitinfoheader(empty)
% 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.');
if ~strict
warning('the working copy is not clean, please commit changes first.');
else
error('the working copy is not clean, please commit changes first.');
end
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.');
if ~strict
warning('the working copy is not in sync with its origin, please push first.');
else
error('the working copy is not in sync with its origin, please push first.');
end
end
% first we get TCV current shot number, to be used for tagging
......@@ -91,9 +125,11 @@ function writegitinfoheader(empty)
descstr=descstr(1:numel(descstr));
fprintf('WARNING: code description string truncated!\n');
end
end
else
descstr = 'n/a';
descstr = 'n/a';
end
fprintf('Code decription string will be set to:\n%s\n', descstr);
......@@ -125,26 +161,27 @@ function writegitinfoheader(empty)
% can be kept
answ = input('Ok to clean build folder [(Y)es/(N)o]?','s');
switch upper(answ)
case 'Y'
otherwise
return
if upper(answ)=='Y'
try
cfg=Simulink.fileGenControl('getConfig');
codegenfolder=cfg.CodeGenFolder;
cleancmd = ['rm -rf ' codegenfolder '/SCD_rtccode*'];
[status,result] = system(cleancmd);
if result~=0
warning('Build folder could not be cleaned properly with the command: %s',cleancmd);
status
else
fprintf('Cleaned with command: %s\n', cleancmd);
end
catch ME
warning('Exception cleaning expcode build folder %s', codegenfolder);
end
end
try
cfg=Simulink.fileGenControl('getConfig');
codegenfolder=cfg.CodeGenFolder;
cleancmd = ['rm -rf ' codegenfolder '/SCD_rtccode*'];
[status,result] = system(cleancmd);
if result~=0
warning('Build folder could not be cleaned properly with the command: %s',cleancmd);
status
else
fprintf('Cleaned with command: %s\n', cleancmd);
end
catch ME
warning('Exception cleaning expcode build folder %s', codegenfolder);
if ~empty
fprintf('All done, remember to publish tag with ''git push --tags''\n');
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment