Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SCDDS-core
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SPC
SCDDS
SCDDS-core
Commits
0a2fa459
Commit
0a2fa459
authored
4 years ago
by
Cristian Galperti
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
build/simulink_codegen/writegitinfoheader.m
+61
-24
61 additions, 24 deletions
build/simulink_codegen/writegitinfoheader.m
with
61 additions
and
24 deletions
build/simulink_codegen/writegitinfoheader.m
+
61
−
24
View file @
0a2fa459
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment