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

SCDconf_setCODEconf allows for an empty codeverstring

parent 5b001c94
No related branches found
No related tags found
No related merge requests found
function writegitinfoheader()
function writegitinfoheader(empty)
% max code description string length
maxdesclen=1024;
% scd expcode info retrieval
try
scd=Simulink.data.evalinGlobal('tcv','scd');
expcode = scd.expcode;
expcodeset=true;
catch ME
warning('No configured expcode found, code description string will not have this info.');
expcodeset=false;
end
% Git checks
% 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")');
% then we try to tag the current rtccode repo
tagname = ['builds/TCV' num2str(curshot)];
str=sprintf('Going to try this git tag: %s [(Y)es/(N)o/A(p)pend]?',tagname);
answ=input(str,'s');
switch upper(answ)
case 'P'
nameapp = input('Type what to append to tag name: ','s');
tagname = [tagname nameapp];
case 'Y'
otherwise
if empty==false
% scd expcode info retrieval
try
scd=Simulink.data.evalinGlobal('tcv','scd');
expcode = scd.expcode;
expcodeset=true;
catch ME
warning('No configured expcode found, code description string will not have this info.');
expcodeset=false;
end
% Git checks
% 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")');
% then we try to tag the current rtccode repo
tagname = ['builds/TCV' num2str(curshot)];
str=sprintf('Going to try this git tag: %s [(Y)es/(N)o/A(p)pend]?',tagname);
answ=input(str,'s');
switch upper(answ)
case 'P'
nameapp = input('Type what to append to tag name: ','s');
tagname = [tagname nameapp];
case 'Y'
otherwise
return
end
tagmsg = input('Type git tag message here: ','s');
tagmsg = strrep(tagmsg,',',';');
tagcmd = ['git tag -f ' tagname ' -m "' tagmsg '"'];
answ = input('Ok to tag [(Y)es/(N)o]?','s');
switch upper(answ)
case 'Y'
otherwise
return
end
[status,result] = system(tagcmd);
if status~=0
fprintf('could not tag, git error: \n%s\n', result);
return
end
tagmsg = input('Type git tag message here: ','s');
tagmsg = strrep(tagmsg,',',';');
tagcmd = ['git tag -f ' tagname ' -m "' tagmsg '"'];
answ = input('Ok to tag [(Y)es/(N)o]?','s');
switch upper(answ)
case 'Y'
otherwise
return
end
[status,result] = system(tagcmd);
if status~=0
fprintf('could not tag, git error: \n%s\n', result);
return
end
taginfocmd = ['git for-each-ref refs/tags/' tagname ' --format="RTCCODE TAG NAME,%(refname),HASH,%(objectname:short),CONTENTS,%(contents:subject),TAGGER,%(taggername),%(taggerdate),FULL OBJECT INFO,%(objecttype),%(objectname)"'];
[status,result] = system(taginfocmd);
if status~=0
fprintf('could not retrieve tag info, git error: \n%s\n', result);
return
end
descstr=result;
answ = input('Include expcode [(Y)es/(N)o]?','s');
switch upper(answ)
case 'Y'
if expcodeset
descstr = ['EXPCODE,' num2str(expcode) ',' descstr];
else
end
taginfocmd = ['git for-each-ref refs/tags/' tagname ' --format="RTCCODE TAG NAME,%(refname),HASH,%(objectname:short),CONTENTS,%(contents:subject),TAGGER,%(taggername),%(taggerdate),FULL OBJECT INFO,%(objecttype),%(objectname)"'];
[status,result] = system(taginfocmd);
if status~=0
fprintf('could not retrieve tag info, git error: \n%s\n', result);
return
end
descstr=result;
answ = input('Include expcode [(Y)es/(N)o]?','s');
switch upper(answ)
case 'Y'
if expcodeset
descstr = ['EXPCODE,' num2str(expcode) ',' descstr];
else
descstr = ['EXPCODE,n/a,' descstr];
end
otherwise
descstr = ['EXPCODE,n/a,' descstr];
end
otherwise
descstr = ['EXPCODE,n/a,' descstr];
end
if numel(descstr)>maxdesclen
descstr=descstr(1:numel(descstr));
fprintf('WARNING: code description string truncated!\n');
end
if numel(descstr)>maxdesclen
descstr=descstr(1:numel(descstr));
fprintf('WARNING: code description string truncated!\n');
end
end
descstr = 'n/a';
fprintf('Code decription string will be set to:\n%s\n', descstr);
[path,~,~]=fileparts(mfilename('fullpath'));
......
......@@ -4,7 +4,7 @@
% otherwise it takes the first argument as the name of the
% configuration settings to be copied into configurationSettings
function [] = SCDconf_setCODEconf(varargin)
function [] = SCDconf_setCODEconf(varargin)
if nargin==0
codeconfname='configurationSettingsCODEicc';
else
......@@ -22,10 +22,10 @@ function [] = SCDconf_setCODEconf(varargin)
answ = input('Perform git tag operations [(Y)es/(N)o]?','s');
switch upper(answ)
case 'Y'
otherwise
return
case 'Y'
writegitinfoheader(false)
otherwise
writegitinfoheader(true)
end
writegitinfoheader
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