Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add increaseVersion function #20

Merged
merged 3 commits into from
Sep 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions ComplementaryScripts/Functions/increaseVersion.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
function increaseVersion(bumpType)
% increaseVersion
%
% Increase version for GEM respositories
%
% Usage: function increaseVersion(bumpType)
%
% Benjam�n J. S�nchez, 2018-07
% Hao Wang, 2018-09-18
%

%Check if in master:
currentBranch = git('rev-parse --abbrev-ref HEAD');
if ~strcmp(currentBranch,'master')
error('ERROR: not in master')
end

%Bump version number:
oldModel = load('../../ModelFiles/mat/humanGEM.mat');
oldVersion = oldModel.ihuman.version
oldVersion = str2double(strsplit(oldVersion,'.'));
newVersion = oldVersion;
switch bumpType
case 'major'
newVersion(1) = newVersion(1) + 1;
newVersion(2) = 0;
newVersion(3) = 0;
case 'minor'
newVersion(2) = newVersion(2) + 1;
newVersion(3) = 0;
case 'patch'
newVersion(3) = newVersion(3) + 1;
otherwise
error('ERROR: invalid input. Use "major", "minor" or "patch"')
end
newVersion = num2str(newVersion,'%d.%d.%d');

%Check if history has been updated:
%fid = fopen('../../history.md','r');
%history = fscanf(fid,'%s');
%fclose(fid);
%if ~contains(history,['human' newVersion ':'])
% error('ERROR: update history.md first')
%end
%To be included

%Load model:
%ihuman = importModel('../../ModelFiles/xml/humanGEM.xml');

%Include tag and save model:
ihuman.version = newVersion;

%Store model as .mat:
save('../../ModelFiles/mat/humanGEM.mat','ihuman');
%deal with other formats later
%exportForGit(ihuman,'humanGEM','..',{'mat', 'txt', 'xlsx', 'xml', 'yml'});

%Update version file:
fid = fopen('../../version.txt','wt');
fprintf(fid,newVersion);
fclose(fid);

end