diff --git a/.artenolis.yml b/.artenolis.yml old mode 100644 new mode 100755 diff --git a/.artenolis/runtests.sh b/.artenolis/runtests.sh old mode 100644 new mode 100755 diff --git a/.gitattributes b/.gitattributes new file mode 100755 index 0000000..69a9a44 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,33 @@ +*.html linguist-documentation=true +*.html linguist-vendored=true +*.gms linguist-vendored=true + +## https://nl.mathworks.com/help/matlab/matlab_prog/set-up-git-source-control.html#buhx2d6-1_3 +*.fig binary +*.mat binary +*.mdl binary +*.mdlp binary +*.mexa64 binary +*.mexw64 binary +*.mexmaci64 binary +*.mlapp binary +*.mldatx binary +*.mlproj binary +*.mlx binary +*.p binary +*.sfx binary +*.sldd binary +*.slreqx binary +*.slmx binary +*.sltx binary +*.slxc binary +*.slx binary merge=mlAutoMerge +*.slxp binary + +## Other common binary file types +*.docx binary +*.exe binary +*.jpg binary +*.pdf binary +*.png binary +*.xlsx binary diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.gitmodules b/.gitmodules old mode 100644 new mode 100755 index 170b920..e69de29 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "external/rdir"] - path = external/rdir - url = https://github.com/LCSB-BioCore/rdir.git diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.rst b/README.rst old mode 100644 new mode 100755 index 58fed45..6d71b98 --- a/README.rst +++ b/README.rst @@ -72,16 +72,39 @@ Some issues that can arise during installation are addressed in the .. end-installation-marker -Do you want to contribute to The COBRA Toolbox? +How contribute to The COBRA Toolbox? ----------------------------------------------- |asciicast| -More information about `the COBRA Toolbox -`__ is given `here +1. Create a github account, with these `instructions +`__. + +2. Create your own fork of the COBRA Toolbox by navigating to +`https://github.com/opencobra/cobratoolbox ` then +in the top-right corner of the page, click Fork__. + +3. Create a local clone of your fork using the commands +$ cd yourCodeDirectory +Replace yourCodeDirectory with your directory of choice, but is important not to place it in a folder that is automatically synced with some cloud drive. + +$ git clone https://github.com/YOUR-USERNAME/cobratoolbox.git fork-cobratoolbox +It is important to clone into a folder named fork-cobratoolbox because that is how MATLAB.devTools recognises your local clone of your COBRA Toolbox fork. + +4. Proceed with the steps below on How do I use the ``MATLAB.devTools``, except start with the following MATLAB command: + +.. code:: matlab + +>> contribute('opencobra/cobratoolbox') + +More information about creating your own fork is avaialable `here +`__. + +More information about `the COBRA Toolbox is available `here `__. -How do I use the ``MATLAB.devTools``? + +How do I use ``MATLAB.devTools``? ------------------------------------- .. begin-getstarted-marker diff --git a/codecov.yml b/codecov.yml old mode 100644 new mode 100755 diff --git a/contribute.m b/contribute.m old mode 100644 new mode 100755 index 75ef232..d20f90f --- a/contribute.m +++ b/contribute.m @@ -1,20 +1,21 @@ function contribute(repoName, printLevel, autoOption) % devTools % -% PURPOSE: displays a menu and calls the respective subfunctions -% -% 1. Start a new branch: -% 2. Select an existing branch to work on. -% 3. Publish a branch. -% 4. Delete a branch. -% 5. Update the fork -% % INPUT: % % repoName: Name of the repository (default: opencobra/cobratoolbox) % printLevel: 0: minimal printout (default) % 1: detailed printout (debug mode) % autoOption: menu option +% 1. Start a new branch: +% 2. Select an existing branch to work on. +% 3. Publish a branch. +% 4. Delete a branch. +% 5. Update the fork +% +% EXAMPLES: +% contribute('opencobra/cobratoolbox') +% contribute('opencobra/COBRA.tutorials') global gitConf global gitCmd @@ -110,7 +111,7 @@ function contribute(repoName, printLevel, autoOption) exitFlag = false; else % initialize the development tools - initDevTools(repoName); + initDevTools(repoName,currentDir); % change to the fork diretory cd(gitConf.fullForkDir); diff --git a/docs/.documenter.enc b/docs/.documenter.enc old mode 100644 new mode 100755 diff --git a/docs/Makefile b/docs/Makefile old mode 100644 new mode 100755 diff --git a/docs/generateJSONList.py b/docs/generateJSONList.py old mode 100644 new mode 100755 diff --git a/docs/requirements.txt b/docs/requirements.txt old mode 100644 new mode 100755 diff --git a/docs/source/_static/browserconfig.xml b/docs/source/_static/browserconfig.xml old mode 100644 new mode 100755 diff --git a/docs/source/_static/img/android-chrome-192x192.png b/docs/source/_static/img/android-chrome-192x192.png old mode 100644 new mode 100755 diff --git a/docs/source/_static/img/android-chrome-384x384.png b/docs/source/_static/img/android-chrome-384x384.png old mode 100644 new mode 100755 diff --git a/docs/source/_static/img/apple-touch-icon.png b/docs/source/_static/img/apple-touch-icon.png old mode 100644 new mode 100755 diff --git a/docs/source/_static/img/favicon-16x16.png b/docs/source/_static/img/favicon-16x16.png old mode 100644 new mode 100755 diff --git a/docs/source/_static/img/favicon-32x32.png b/docs/source/_static/img/favicon-32x32.png old mode 100644 new mode 100755 diff --git a/docs/source/_static/img/favicon.ico b/docs/source/_static/img/favicon.ico old mode 100644 new mode 100755 diff --git a/docs/source/_static/img/logo_devTools.png b/docs/source/_static/img/logo_devTools.png old mode 100644 new mode 100755 diff --git a/docs/source/_static/img/mstile-150x150.png b/docs/source/_static/img/mstile-150x150.png old mode 100644 new mode 100755 diff --git a/docs/source/_static/img/safari-pinned-tab.svg b/docs/source/_static/img/safari-pinned-tab.svg old mode 100644 new mode 100755 diff --git a/docs/source/_static/json/manifest.json b/docs/source/_static/json/manifest.json old mode 100644 new mode 100755 diff --git a/docs/source/bestpractices.rst b/docs/source/bestpractices.rst old mode 100644 new mode 100755 diff --git a/docs/source/cite.rst b/docs/source/cite.rst old mode 100644 new mode 100755 diff --git a/docs/source/conf.py b/docs/source/conf.py old mode 100644 new mode 100755 diff --git a/docs/source/contents.rst b/docs/source/contents.rst old mode 100644 new mode 100755 diff --git a/docs/source/contr_cobratoolbox.rst b/docs/source/contr_cobratoolbox.rst old mode 100644 new mode 100755 diff --git a/docs/source/contr_cobratutorials.rst b/docs/source/contr_cobratutorials.rst old mode 100644 new mode 100755 diff --git a/docs/source/contr_otherrepo.rst b/docs/source/contr_otherrepo.rst old mode 100644 new mode 100755 diff --git a/docs/source/contribute.rst b/docs/source/contribute.rst old mode 100644 new mode 100755 diff --git a/docs/source/faq.rst b/docs/source/faq.rst old mode 100644 new mode 100755 diff --git a/docs/source/funding.rst b/docs/source/funding.rst old mode 100644 new mode 100755 diff --git a/docs/source/getstarted.rst b/docs/source/getstarted.rst old mode 100644 new mode 100755 diff --git a/docs/source/index.rst b/docs/source/index.rst old mode 100644 new mode 100755 diff --git a/docs/source/installation.rst b/docs/source/installation.rst old mode 100644 new mode 100755 diff --git a/docs/source/modules/index.rst b/docs/source/modules/index.rst old mode 100644 new mode 100755 diff --git a/docs/source/prerequisites.rst b/docs/source/prerequisites.rst old mode 100644 new mode 100755 diff --git a/docs/source/sphinxext/__init__.py b/docs/source/sphinxext/__init__.py old mode 100644 new mode 100755 diff --git a/docs/source/sphinxext/github_linkcode.py b/docs/source/sphinxext/github_linkcode.py old mode 100644 new mode 100755 diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst old mode 100644 new mode 100755 diff --git a/docs/source/troubleshooting/cobratoolbox.rst b/docs/source/troubleshooting/cobratoolbox.rst old mode 100644 new mode 100755 diff --git a/docs/source/troubleshooting/cobratutorials.rst b/docs/source/troubleshooting/cobratutorials.rst old mode 100644 new mode 100755 diff --git a/external/rdir b/external/rdir deleted file mode 160000 index 0bfa4a3..0000000 --- a/external/rdir +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0bfa4a3b623bf3cdfa1e707c4932c47d1035c5f3 diff --git a/src/addKeyToKnownHosts.m b/src/addKeyToKnownHosts.m old mode 100644 new mode 100755 diff --git a/src/checkBranchExistence.m b/src/checkBranchExistence.m old mode 100644 new mode 100755 diff --git a/src/checkDevTools.m b/src/checkDevTools.m old mode 100644 new mode 100755 diff --git a/src/checkLocalFork.m b/src/checkLocalFork.m old mode 100644 new mode 100755 diff --git a/src/checkRemoteBranchExistence.m b/src/checkRemoteBranchExistence.m old mode 100644 new mode 100755 index 2fa0086..32f5015 --- a/src/checkRemoteBranchExistence.m +++ b/src/checkRemoteBranchExistence.m @@ -37,7 +37,7 @@ [status_curl_org, result_curl_org] = system(['curl -s -k --head ' tmpRepoName_org '/tree/' branchName]); - if status_curl_up == 0 && contains(result_curl_up, '200 OK') + if status_curl_up == 0 && contains(result_curl_up, '200') printMsg(mfilename, ['The branch <' branchName '> exists remotely on upstream.']); branchExists_up = true; else @@ -45,7 +45,7 @@ branchExists_up = false; end - if status_curl_org == 0 && contains(result_curl_org, '200 OK') + if status_curl_org == 0 && contains(result_curl_org, '200') printMsg(mfilename, ['The branch <' branchName '> exists remotely on origin.']); branchExists_org = true; else diff --git a/src/checkRemoteFork.m b/src/checkRemoteFork.m old mode 100644 new mode 100755 index 3c395aa..d664b8c --- a/src/checkRemoteFork.m +++ b/src/checkRemoteFork.m @@ -22,7 +22,7 @@ function checkRemoteFork() [status_curl, result_curl] = system(['curl -s -k --head ', gitConf.remoteServerName, gitConf.userName, '/', gitConf.remoteRepoName]); % check if the URL exists - if status_curl == 0 && ~isempty(strfind(result_curl, '200 OK')) + if status_curl == 0 && ~isempty(strfind(result_curl, '200')) gitConf.forkURL = [gitConf.remoteServerName, gitConf.userName, '/', gitConf.remoteRepoName, '.git']; printMsg(mfilename, ['The original repository has already been forked on Github (', gitConf.forkURL,').']); diff --git a/src/checkStatus.m b/src/checkStatus.m old mode 100644 new mode 100755 diff --git a/src/checkSystem.m b/src/checkSystem.m old mode 100644 new mode 100755 index 828fcc8..cf8f249 --- a/src/checkSystem.m +++ b/src/checkSystem.m @@ -19,19 +19,19 @@ function checkSystem(callerName, repoName, printLevel) global gitCmd % set the callerName - if ~exist('printLevel', 'var') + if ~exist('callerName', 'var') callerName = ''; else callerName = ['(caller: ', callerName, ')']; end % set the repoName if not given - if nargin < 2 || ~exist('repoName', 'var') + if ~exist('repoName', 'var') repoName = 'opencobra/cobratoolbox'; end - if ~exist('printLevel', 'var') && isempty(gitConf) - printLevel = 0; + if ~exist('printLevel', 'var') + printLevel = 1;%by default print end % if a configuration has already been set, configure the devTools accordingly @@ -39,6 +39,7 @@ function checkSystem(callerName, repoName, printLevel) % default configuration of the devTools is the DEFAULTREPONAME repository confDevTools(repoName, 'printLevel', printLevel); else + gitConf.printLevel = printLevel; % write instructions how to reset the devTools when they already configured if strcmpi(callerName, 'contribute') fprintf('\n'); diff --git a/src/checkoutBranch.m b/src/checkoutBranch.m old mode 100644 new mode 100755 diff --git a/src/cloneFork.m b/src/cloneFork.m old mode 100644 new mode 100755 diff --git a/src/confDevTools.m b/src/confDevTools.m old mode 100644 new mode 100755 index dd7811f..6bdd89e --- a/src/confDevTools.m +++ b/src/confDevTools.m @@ -67,7 +67,13 @@ function confDevTools(repoName, varargin) % check if the remoteRepoURL exists before proceeding [status_curl, result_curl] = system(['curl -s -k --head ', tmpRemoteRepoURL]); - if ~(status_curl == 0 && ~isempty(strfind(result_curl, '200 OK'))) + if contains(result_curl,'not found (required by curl)') + disp('Cannot find the required curl libraries. Try replacing matlab libcurl with system libcurl, e.g.:') + disp('mv /usr/local/bin/MATLAB/R2021a/bin/glnxa64/libcurl.so.4 /usr/local/bin/MATLAB/R2021a/bin/glnxa64/libcurl.so.4_matlab') + disp('cp /usr/lib/x86_64-linux-gnu/libcurl.so.4 /usr/local/bin/MATLAB/R2021a/bin/glnxa64/libcurl.so.4') + end + + if ~(status_curl == 0 && ~isempty(strfind(result_curl, '200'))) error([' [', mfilename, '] The URL (' remoteRepoURL ') is not reachable or does not exist.']); end diff --git a/src/configureFork.m b/src/configureFork.m old mode 100644 new mode 100755 index 2071f95..a141916 --- a/src/configureFork.m +++ b/src/configureFork.m @@ -26,7 +26,10 @@ function configureFork() % retrieve a list of remotes [status_gitRemote, result_gitRemote] = system('git remote -v'); - if status_gitRemote == 0 && ~isempty(strfind(result_gitRemote, 'origin')) && ~isempty(strfind(result_gitRemote, 'upstream')) && ~isempty(strfind(result_gitRemote, gitConf.userName)) && ~isempty(strfind(result_gitRemote, gitConf.remoteUserName)) + if status_gitRemote == 0 && contains(result_gitRemote, 'origin')... + && contains(result_gitRemote, 'upstream')... + && contains(result_gitRemote, gitConf.userName)... + && contains(result_gitRemote, gitConf.remoteUserName) printMsg(mfilename, 'Your fork is properly configured.'); else [status_gitRemoteAdd, result_gitRemoteAdd] = system(['git remote add upstream ', gitConf.remoteRepoURL]); diff --git a/src/deleteContribution.m b/src/deleteContribution.m old mode 100644 new mode 100755 index f8d1613..77bfd5f --- a/src/deleteContribution.m +++ b/src/deleteContribution.m @@ -113,7 +113,7 @@ function deleteContribution(branchName) fprintf([gitCmd.lead, originCall, 'The remote (upstream) <', branchName, '> branch has been deleted.', gitCmd.success, gitCmd.trail]); else fprintf(result_gitPush); - error([gitCmd.lead, ' [', mfilename,'] The remote (upstream) <', branchName,'> branch could not be deleted.', gitCmd.fail]); + warning([gitCmd.lead, ' [', mfilename,'] The remote (upstream) <', branchName,'> branch could not be deleted.', gitCmd.fail]); end end end diff --git a/src/getCurrentBranchName.m b/src/getCurrentBranchName.m old mode 100644 new mode 100755 diff --git a/src/history.m b/src/history.m old mode 100644 new mode 100755 diff --git a/src/initContribution.m b/src/initContribution.m old mode 100644 new mode 100755 diff --git a/src/initDevTools.m b/src/initDevTools.m old mode 100644 new mode 100755 index dca9b56..0422ce7 --- a/src/initDevTools.m +++ b/src/initDevTools.m @@ -1,4 +1,4 @@ -function initDevTools(repoName) +function initDevTools(repoName,currentDir,printLevel) % Initializes the development tools (username and email are requested if not configured) % % USAGE: @@ -8,8 +8,8 @@ function initDevTools(repoName) % INPUT: % repoName: Name of the repository for which the devTools shall % be configured (default: `opencobra/cobratoolbox`) -% .. Author: -% - Laurent Heirendt +% .. Authors: +% - Laurent Heirendt, Ronan Fleming global gitConf global gitCmd @@ -20,13 +20,18 @@ function initDevTools(repoName) if ~exist('repoName', 'var') repoName = DEFAULTREPONAME; end - + if ~exist('currentDir', 'var') + currentDir = pwd; + end + if ~exist('printLevel', 'var') + printLevel = 1;%by default print to screen + end resetDevToolsFlag = true; finishup = onCleanup(@() resetDevTools()); % check the system and set the configuration - checkSystem(mfilename, repoName); + checkSystem(mfilename, repoName, printLevel); if ~isfield(gitConf, 'userName'), gitConf.userName = []; end if ~isfield(gitConf, 'localDir'), gitConf.localDir = []; end @@ -96,8 +101,14 @@ function initDevTools(repoName) % retrieve the directory of the fork from the local git configuration [~, result_gitConfForkDirGet] = system(['git config --get user.', gitConf.leadForkDirName, gitConf.nickName, '.path']); - gitConf.fullForkDir = strtrim(result_gitConfForkDirGet); - gitConf.localDir = gitConf.fullForkDir; + if ~isempty(result_gitConfForkDirGet) + gitConf.fullForkDir = strtrim(result_gitConfForkDirGet); + gitConf.localDir = gitConf.fullForkDir; + else + fprintf('%s\n','No existing information about the location of the fork directory.') + gitConf.fullForkDir = ''; + gitConf.localDir = ''; + end % check if the fork exists remotely checkRemoteFork(); @@ -108,7 +119,7 @@ function initDevTools(repoName) createDir = false; while ~createDir - reply = input([gitCmd.lead, originCall, ' -> Please define the location of your fork\n current: ', strrep(pwd, '\','\\'),'\n Enter the path(press ENTER to use the current path): '], 's'); + reply = input([gitCmd.lead, originCall, ' -> Please define the location of your fork\n current: ', strrep(currentDir, '\','\\'),'\n Enter the path(press ENTER to use the current path): '], 's'); % define the local directory as the current directory if the reply is empty if isempty(reply) @@ -187,7 +198,14 @@ function initDevTools(repoName) % only update if there are no local changes if status_gitStatus == 0 && isempty(result_gitStatus) - updateFork(true); + reply = input([gitCmd.lead, originCall, ' Do you want to update your fork? Y/N [Y]:'], 's'); + + % update fork if requested + if (isempty(reply) || strcmpi(reply, 'y') || strcmpi(reply, 'yes')) + updateFork(true); + end + + else printMsg(mfilename, 'The local fork cannot be updated as you have uncommitted changes.', [gitCmd.fail, gitCmd.trail]); end diff --git a/src/listBranches.m b/src/listBranches.m old mode 100644 new mode 100755 diff --git a/src/matlab/m2mlx.m b/src/matlab/m2mlx.m new file mode 100755 index 0000000..78a226e --- /dev/null +++ b/src/matlab/m2mlx.m @@ -0,0 +1,16 @@ +function mlxFile = m2mlx(mFile) + +if strcmp(version('-release'), '2016b') + openAndConvert = @matlab.internal.richeditor.openAndSave; +else + openAndConvert = @matlab.internal.liveeditor.openAndSave; +end + +[FILEPATH,NAME,~] = fileparts(mFile); + +mlxFile=[FILEPATH,NAME,'.mlx']; + +openAndConvert(mFile,mlxFile) + +end + diff --git a/src/matlab/mlx2m.m b/src/matlab/mlx2m.m new file mode 100755 index 0000000..59571ae --- /dev/null +++ b/src/matlab/mlx2m.m @@ -0,0 +1,16 @@ +function mFile = mlx2m(mlxFile) + +if strcmp(version('-release'), '2016b') + openAndConvert = @matlab.internal.richeditor.openAndConvert; +else + openAndConvert = @matlab.internal.liveeditor.openAndConvert; +end + +[FILEPATH,NAME,~] = fileparts(mlxFile); + +mFile=[FILEPATH filesep NAME,'.m']; + +openAndConvert(mlxFile,mFile) + +end + diff --git a/src/openPR.m b/src/openPR.m old mode 100644 new mode 100755 index df87a44..502706a --- a/src/openPR.m +++ b/src/openPR.m @@ -35,9 +35,15 @@ function openPR(branchName) % check if this URL exists [status_curl, result_curl] = system(['curl -s -k --head ', prURL]); - - if status_curl == 0 && ~isempty(strfind(result_curl, '200 OK')) - fprintf([gitCmd.lead, originCall, 'You can open a pull request (PR) by clicking on \n\n\t', prURL, '?expand=1\n\n']); + + if status_curl == 0 && ~isempty(strfind(result_curl, '200')) + % url = 'https://www.mathworks.com'; + % sitename = 'The MathWorks Web Site'; + % fprintf('%s\n',url,sitename) + fprintf([gitCmd.lead, originCall, 'You can open a pull request (PR) by clicking on \n']) + url = [prURL '?expand=1']; + sitename = url; + fprintf('%s\n',url,sitename) fprintf([gitCmd.lead, originCall, 'Please start a new branch by running "contribute" and selecting "1" after your pull request (PR) has been reviewed and merged.\n']); else fprintf(result_curl); diff --git a/src/printMsg.m b/src/printMsg.m old mode 100644 new mode 100755 diff --git a/src/resetDevTools.m b/src/resetDevTools.m old mode 100644 new mode 100755 diff --git a/src/resetLocalFork.m b/src/resetLocalFork.m old mode 100644 new mode 100755 diff --git a/src/submitContribution.m b/src/submitContribution.m old mode 100644 new mode 100755 index 6b12994..b40f521 --- a/src/submitContribution.m +++ b/src/submitContribution.m @@ -78,6 +78,8 @@ function submitContribution(branchName) for i = 1:length(arrResult) tmpFileName = arrResult(i); + + % split the file name into 2 parts tmpFileNameChunks = strsplit(tmpFileName{1}, ' '); @@ -96,6 +98,10 @@ function submitContribution(branchName) fullFileName = tmpFileNameChunks{k+1}; end end + + + [FILEPATH,NAME,EXT] = fileparts(fullFileName); + % add deleted files if ~isempty(tmpFileName) && ~isempty(strfind(fullFileStatus, 'D')) @@ -108,7 +114,7 @@ function submitContribution(branchName) printMsg(mfilename, ['The file ', fullFileName, ' has been added to the stage.']); else fprintf(result); - error([gitCmd.lead, ' [', mfilename,'] The file ', fullFileName, ' could not be added to the stage.', gitCmd.fail]); + warning([gitCmd.lead, ' [', mfilename,'] The file ', fullFileName, ' could not be added to the stage.', gitCmd.fail]); end end end @@ -127,6 +133,18 @@ function submitContribution(branchName) error([gitCmd.lead, ' [', mfilename,'] The file <', fullFileName, '> could not be added to the stage.', gitCmd.fail]); end end + + %if this is an mlx file, create the m file then add it + if strcmp(EXT,'.mlx') + mlxFile=which(fullFileName); + if isempty(mlxFile) + error([fullFileName ' not in matlab path']) + else + [FILEPATH,NAME,EXT] = fileparts(mlxFile); + mFile = mlx2m(mlxFile); + [status, result] = system(['git add ', mFile]); + end + end end % add untracked files diff --git a/src/updateDevTools.m b/src/updateDevTools.m old mode 100644 new mode 100755 diff --git a/src/updateFork.m b/src/updateFork.m old mode 100644 new mode 100755 index 81a58c3..21e1c2d --- a/src/updateFork.m +++ b/src/updateFork.m @@ -55,7 +55,7 @@ function updateFork(force) % check if the develop branch exists on the fork [status_curl, result_curl] = system(['curl -s -k --head ', gitConf.remoteServerName, gitConf.userName, '/', gitConf.remoteRepoName, '/tree/develop']); - if status_curl == 0 && ~isempty(strfind(result_curl, '200 OK')) + if status_curl == 0 && ~isempty(strfind(result_curl, '200')) % pull eventual changes from other contributors or administrators [status_gitFetchOrigin, result_gitFetchOrigin] = system('git fetch origin'); % no pull if status_gitFetchOrigin == 0 @@ -79,7 +79,7 @@ function updateFork(force) % loop through the list of branches for k = 1:length(branches) - % checkout the branch k + % checkout the branch k if status_gitBranch == 0 && ~isempty(strfind(resultList, branches{k})) [status_gitCheckout, result_gitCheckout] = system(['git checkout ', branches{k}]); @@ -161,6 +161,8 @@ function updateFork(force) fprintf(result_gitPush); error([gitCmd.lead, ' [', mfilename,'] Impossible to update the <', branches{k}, '> branch on your fork (', gitConf.forkURL, ').', gitCmd.fail]); end + else + printMsg(mfilename, ['The local <', branches{k}, '> branch was already level with the remote origin and upstream. <', branches{k}, '>']); end end end diff --git a/src/updateSubmodules.m b/src/updateSubmodules.m old mode 100644 new mode 100755 index 8ce009b..dc55f8a --- a/src/updateSubmodules.m +++ b/src/updateSubmodules.m @@ -6,7 +6,7 @@ function updateSubmodules() % updateSubmodules() % % .. Author: -% - Laurent Heirendt +% - Laurent Heirendt, Ronan Fleming global gitConf global gitCmd @@ -36,45 +36,75 @@ function updateSubmodules() error([gitCmd.lead, ' [', mfilename,'] The submodules could not be initialized.', gitCmd.fail]); end - % retrieve the count for each submodule - [status_gitSubmoduleCount, result_gitSubmoduleCount] = system('git submodule foreach --recursive git rev-list --count origin/master...HEAD'); - - % split the array at line breaks - arrResult = regexp(result_gitSubmoduleCount,'\n+','split'); %strsplit is not compatible with older versions of MATLAB - arrResult = strtrim(arrResult); - - % filter out the empty ones - arrResult = arrResult(~cellfun(@isempty, arrResult)); - - % calculate the total number of changes - sumChanges = 0; - nSubmodules = length(arrResult)/2; - for k = 1:nSubmodules - sumChanges = sumChanges + str2num(arrResult{2*k}); - end - - % update submodules - [status_gitSubmodule, result_gitSubmodule] = system('git submodule update'); - - if status_gitSubmodule == 0 - printMsg(mfilename, 'The submodules have been initialized.'); + if 0 + % retrieve the count for each submodule + [status_gitSubmoduleCount, result_gitSubmoduleCount] = system('git submodule foreach --recursive git rev-list --count origin/master...HEAD'); + + % split the array at line breaks + arrResult = regexp(result_gitSubmoduleCount,'\n+','split'); %strsplit is not compatible with older versions of MATLAB + arrResult = strtrim(arrResult); + + % filter out the empty ones + arrResult = arrResult(~cellfun(@isempty, arrResult)); + + % calculate the total number of changes + sumChanges = 0; + nSubmodules = length(arrResult)/2; + for k = 1:nSubmodules + sumChanges = sumChanges + str2num(arrResult{2*k}); + end + + % update submodules + [status_gitSubmodule, result_gitSubmodule] = system('git submodule update'); + + if status_gitSubmodule == 0 + printMsg(mfilename, 'The submodules have been updated.'); + else + fprintf(result_gitSubmodule); + error([gitCmd.lead, ' [', mfilename,'] The submodules could not be updated.', gitCmd.fail]); + end + + % update the submodules + if sumChanges > 0 + % reset each submodule + [status_gitReset result_gitReset] = system('git submodule foreach --recursive git reset --hard'); + if status_gitReset == 0 + printMsg(mfilename, 'The submodules have been reset.'); + else + fprintf(result_gitReset); + error([gitCmd.lead, ' [', mfilename,'] The submodules could not be reset.', gitCmd.fail]); + end + end else - fprintf(result_gitSubmodule); - error([gitCmd.lead, ' [', mfilename,'] The submodules could not be initialized.', gitCmd.fail]); - end - - % update the submodules - if sumChanges > 0 - % reset each submodule - [status_gitReset result_gitReset] = system('git submodule foreach --recursive git reset --hard'); - if status_gitReset == 0 - printMsg(mfilename, 'The submodules have been reset.'); + % update submodules + [status_gitSubmodule, result_gitSubmodule] = system('git submodule update'); + + if status_gitSubmodule == 0 + printMsg(mfilename, 'The submodules have been updated.'); else - fprintf(result_gitReset); - error([gitCmd.lead, ' [', mfilename,'] The submodules could not be reset.', gitCmd.fail]); + fprintf(result_gitSubmodule); + error([gitCmd.lead, ' [', mfilename,'] The submodules could not be updated.', gitCmd.fail]); end - end + %Check for changes to submodules + [status_gitSubmodule, result_gitSubmodule] = system('git submodule foreach git status'); + if status_gitSubmodule==0 + if contains(result_gitSubmodule,'modified') || contains(result_gitSubmodule,'Untracked files') + submoduleWarning = 1; + [status_gitSubmodule, result_gitSubmodule] = system('git submodule foreach git stash push -u'); + if status_gitSubmodule==0 + fprintf('\n%s\n','***Local changes to submodules have been stashed. See https://git-scm.com/docs/git-stash.') + disp(result_gitSubmodule) + end + end + end + + % update submodules + [status_gitSubmodule, result_gitSubmodule] = system('git submodule foreach git checkout master');% 30/9/21 RF submodules point to master + [status_gitSubmodule, result_gitSubmodule] = system('git submodule foreach git pull');% 30/9/21 RF pull in remote submodule changes to master branch + + end + % restore global configuration by unsetting http.sslVerify [status_setSSLVerify, result_setSSLVerify] = system('git config --global --unset http.sslVerify'); diff --git a/test/inputCI.txt b/test/inputCI.txt old mode 100644 new mode 100755 diff --git a/test/launchTests.m b/test/launchTests.m old mode 100644 new mode 100755 diff --git a/test/testCheckSystem.m b/test/testCheckSystem.m old mode 100644 new mode 100755