diff --git a/matlab/TCV_IMAS/tcv_get_deploymentinfo.m b/matlab/TCV_IMAS/tcv_get_deploymentinfo.m new file mode 100644 index 0000000000000000000000000000000000000000..576b97c706bbd09eee4b2b8dc38e0edc57511db7 --- /dev/null +++ b/matlab/TCV_IMAS/tcv_get_deploymentinfo.m @@ -0,0 +1,55 @@ +function info = tcv_get_deploymentinfo(filepath) + % Reads a deployment info file and extracts relevant details + % Author: L. Simons + % Date: 07/03/25 + % + % Args: + % filepath: Path to the text file + % + % Returns: + % info: Struct containing extracted information + + % Initialize output struct + info = struct(); + info.repository=fileparts(filepath); + + % Check if file exists + if exist(filepath, 'file') ~= 2 + error('File does not exist: %s', filepath); + end + + % Open file for reading + fid = fopen(filepath, 'r'); + if fid == -1 + error('Could not open file: %s', filepath); + end + + % Read file line by line + while ~feof(fid) + line = fgetl(fid); + if ischar(line) + tokens = regexp(line, '^(\w+):\s(.+)$', 'tokens'); + if ~isempty(tokens) + key = tokens{1}{1}; + value = strtrim(tokens{1}{2}); + + % Store relevant fields in the struct + switch key + case 'DEPLOYMENT_DATE' + info.deployment_date = value; + case 'GIT_TAG' + info.git_tag = value; + case 'GIT_COMMIT' + info.git_commit = value; + case 'GIT_TAG_DATE' + info.git_tag_date = value; + case 'GITLAB_PROJECT_URL' + info.gitlab_project_url = value; + end + end + end + end + + % Close the file + fclose(fid); +end