From 443771ab73452d9788cd0f5ad6867282351315ea Mon Sep 17 00:00:00 2001 From: rmtfleming Date: Fri, 23 Oct 2020 13:27:17 +0100 Subject: [PATCH 01/15] update to documentation --- README.rst | 24 ++++++++++++++++++++++-- src/openPR.m | 10 ++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 58fed45..b2193ed 100644 --- a/README.rst +++ b/README.rst @@ -72,16 +72,36 @@ 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| +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``? +More information about creating your own fork is avaialable `here +`__. + More information about `the COBRA Toolbox `__ is given `here `__. -How do I use the ``MATLAB.devTools``? + +How do I use ``MATLAB.devTools``? ------------------------------------- .. begin-getstarted-marker diff --git a/src/openPR.m b/src/openPR.m index df87a44..5539f27 100644 --- 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']); + % 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); From 397bd7a13fec74dafa55f502ab96a864131ca755 Mon Sep 17 00:00:00 2001 From: rmtfleming Date: Fri, 23 Oct 2020 14:24:09 +0100 Subject: [PATCH 02/15] update to documentation --- README.rst | 11 +++++++---- contribute.m | 13 +++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index b2193ed..6d71b98 100644 --- a/README.rst +++ b/README.rst @@ -84,7 +84,6 @@ How contribute to The COBRA Toolbox? `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. @@ -92,12 +91,16 @@ Replace yourCodeDirectory with your directory of choice, but is important not to $ 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``? +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 given `here +More information about `the COBRA Toolbox is available `here `__. diff --git a/contribute.m b/contribute.m index 75ef232..1386b62 100644 --- a/contribute.m +++ b/contribute.m @@ -1,20 +1,17 @@ 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 global gitConf global gitCmd From ce668b2252458ca14c14b01bbeaa8d1905494d2c Mon Sep 17 00:00:00 2001 From: Ronan Fleming Date: Tue, 10 Nov 2020 09:40:37 +0000 Subject: [PATCH 03/15] support for mlx --- contribute.m | 2 +- src/initDevTools.m | 4 ++-- src/matlab/m2mlx.m | 16 ++++++++++++++++ src/matlab/mlx2m.m | 16 ++++++++++++++++ src/submitContribution.m | 18 ++++++++++++++++++ 5 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 src/matlab/m2mlx.m create mode 100644 src/matlab/mlx2m.m diff --git a/contribute.m b/contribute.m index 1386b62..9dffb16 100644 --- a/contribute.m +++ b/contribute.m @@ -107,7 +107,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/src/initDevTools.m b/src/initDevTools.m index dca9b56..ef0bb2e 100644 --- a/src/initDevTools.m +++ b/src/initDevTools.m @@ -1,4 +1,4 @@ -function initDevTools(repoName) +function initDevTools(repoName,currentDir) % Initializes the development tools (username and email are requested if not configured) % % USAGE: @@ -108,7 +108,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) diff --git a/src/matlab/m2mlx.m b/src/matlab/m2mlx.m new file mode 100644 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 100644 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/submitContribution.m b/src/submitContribution.m index 6b12994..0cd4f34 100644 --- 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')) @@ -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 mlx 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 From 9e557b93add7fe6882f4418f09c6f845d891f254 Mon Sep 17 00:00:00 2001 From: Ronan Fleming Date: Wed, 10 Feb 2021 19:32:02 +0000 Subject: [PATCH 04/15] 200 rather than 200 OK --- src/checkRemoteBranchExistence.m | 4 ++-- src/checkRemoteFork.m | 2 +- src/confDevTools.m | 2 +- src/openPR.m | 2 +- src/updateFork.m | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/checkRemoteBranchExistence.m b/src/checkRemoteBranchExistence.m index 2fa0086..32f5015 100644 --- 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 index 3c395aa..d664b8c 100644 --- 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/confDevTools.m b/src/confDevTools.m index dd7811f..da198a6 100644 --- a/src/confDevTools.m +++ b/src/confDevTools.m @@ -67,7 +67,7 @@ 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 ~(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/openPR.m b/src/openPR.m index 5539f27..502706a 100644 --- a/src/openPR.m +++ b/src/openPR.m @@ -36,7 +36,7 @@ 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')) + if status_curl == 0 && ~isempty(strfind(result_curl, '200')) % url = 'https://www.mathworks.com'; % sitename = 'The MathWorks Web Site'; % fprintf('%s\n',url,sitename) diff --git a/src/updateFork.m b/src/updateFork.m index 81a58c3..8b7bee4 100644 --- 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 From a8cb5b24daed8ea0e9f8e7d6e1dc32cfa9802a93 Mon Sep 17 00:00:00 2001 From: Ronan Fleming Date: Wed, 17 Mar 2021 00:00:04 +0000 Subject: [PATCH 05/15] use current directory as backup --- src/configureFork.m | 5 ++++- src/initDevTools.m | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/configureFork.m b/src/configureFork.m index 2071f95..a141916 100644 --- 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/initDevTools.m b/src/initDevTools.m index ef0bb2e..603ed43 100644 --- a/src/initDevTools.m +++ b/src/initDevTools.m @@ -96,8 +96,13 @@ function initDevTools(repoName,currentDir) % 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=currentDir; + gitConf.localDir = gitConf.fullForkDir; + else + gitConf.fullForkDir = strtrim(result_gitConfForkDirGet); + gitConf.localDir = gitConf.fullForkDir; + end % check if the fork exists remotely checkRemoteFork(); From 6a919d4cf9c5bade0be15021c636a87b028ba949 Mon Sep 17 00:00:00 2001 From: Ronan Fleming Date: Thu, 29 Apr 2021 09:44:08 +0100 Subject: [PATCH 06/15] default to current dir --- src/initDevTools.m | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/initDevTools.m b/src/initDevTools.m index 603ed43..54581ee 100644 --- a/src/initDevTools.m +++ b/src/initDevTools.m @@ -8,8 +8,8 @@ function initDevTools(repoName,currentDir) % 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,7 +20,9 @@ function initDevTools(repoName,currentDir) if ~exist('repoName', 'var') repoName = DEFAULTREPONAME; end - + if ~exist('currentDir', 'var') + currentDir = pwd; + end resetDevToolsFlag = true; finishup = onCleanup(@() resetDevTools()); @@ -97,6 +99,7 @@ function initDevTools(repoName,currentDir) % retrieve the directory of the fork from the local git configuration [~, result_gitConfForkDirGet] = system(['git config --get user.', gitConf.leadForkDirName, gitConf.nickName, '.path']); if isempty(result_gitConfForkDirGet) + fprintf('%s%s%s\n','Attempting to progress by assuming the current directory (', currentDir, ') is a fork directory.') gitConf.fullForkDir=currentDir; gitConf.localDir = gitConf.fullForkDir; else From e303ec9fed036bf1256c89d76c8fc25b14aac214 Mon Sep 17 00:00:00 2001 From: WegrzynAB Date: Mon, 3 May 2021 20:21:28 +0200 Subject: [PATCH 07/15] remove submodule rdir as it does not exist --- .gitmodules | 3 --- external/rdir | 1 - 2 files changed, 4 deletions(-) delete mode 160000 external/rdir diff --git a/.gitmodules b/.gitmodules index 170b920..e69de29 100644 --- 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/external/rdir b/external/rdir deleted file mode 160000 index 0bfa4a3..0000000 --- a/external/rdir +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0bfa4a3b623bf3cdfa1e707c4932c47d1035c5f3 From 3ea6f38ba2d72d420ff3fa213b02b5c0e2353af9 Mon Sep 17 00:00:00 2001 From: WegrzynAB Date: Mon, 3 May 2021 20:40:59 +0200 Subject: [PATCH 08/15] ask to confirm default dir --- src/initDevTools.asv | 212 +++++++++++++++++++++++++++++++++++++++++++ src/initDevTools.m | 10 +- 2 files changed, 217 insertions(+), 5 deletions(-) create mode 100644 src/initDevTools.asv diff --git a/src/initDevTools.asv b/src/initDevTools.asv new file mode 100644 index 0000000..91a5c8c --- /dev/null +++ b/src/initDevTools.asv @@ -0,0 +1,212 @@ +function initDevTools(repoName,currentDir) +% Initializes the development tools (username and email are requested if not configured) +% +% USAGE: +% +% initDevTools(repoName) +% +% INPUT: +% repoName: Name of the repository for which the devTools shall +% be configured (default: `opencobra/cobratoolbox`) +% .. Authors: +% - Laurent Heirendt, Ronan Fleming + + global gitConf + global gitCmd + global resetDevToolsFlag + global DEFAULTREPONAME + + % set the repoName if not given + if ~exist('repoName', 'var') + repoName = DEFAULTREPONAME; + end + if ~exist('currentDir', 'var') + currentDir = pwd; + end + resetDevToolsFlag = true; + + finishup = onCleanup(@() resetDevTools()); + + % check the system and set the configuration + checkSystem(mfilename, repoName); + + if ~isfield(gitConf, 'userName'), gitConf.userName = []; end + if ~isfield(gitConf, 'localDir'), gitConf.localDir = []; end + + % parse the remoteRepoURL + sepIndices = strfind(gitConf.remoteRepoURL, '/'); + gitConf.remoteServerName = gitConf.remoteRepoURL(1:sepIndices(3)); + gitConf.remoteRepoName = gitConf.remoteRepoURL(sepIndices(4) + 1:end - 4); + gitConf.remoteUserName = gitConf.remoteRepoURL(sepIndices(3) + 1:sepIndices(4) - 1); + + % ignore case for the current fork (avoids problems for untracked files with case conflicts) + [status_gitIgnoreCase, result_gitIgnoreCase] = system('git config core.ignorecase true'); + + % retrieve the user name + [status_gitConfUserGet, result_gitConfUserGet] = system('git config --get user.github-username'); + gitConf.userName = strtrim(result_gitConfUserGet); + + if gitConf.printLevel > 0 + originCall = [' [', mfilename, '] ']; + else + originCall = ''; + end + + if status_gitConfUserGet == 0 && isempty(strfind(gitConf.userName, ' ')) + fprintf([gitCmd.lead, originCall, 'Your Github username is: ', gitConf.userName, '. ', gitCmd.success, gitCmd.trail]); + else + printMsg(mfilename, 'The Github username could not be retrieved or is not valid.', [gitCmd.fail, gitCmd.trail]); + + % request the Github username if it is not known or if the username contains whitespaces + if isempty(gitConf.userName) || ~isempty(strfind(gitConf.userName, ' ')) + gitConf.userName = input([gitCmd.lead, originCall, ' -> Please enter your Github username: '], 's'); + [status_gitConfUserSet, result_gitConfUserSet] = system(['git config --global --add user.github-username "', gitConf.userName, '"']); + if status_gitConfUserSet == 0 + fprintf([gitCmd.lead, originCall, 'Your Github username is: ', gitConf.userName, '. ', gitCmd.success, gitCmd.trail]); + else + fprintf(result_gitConfUserSet); + error([gitCmd.lead, ' [', mfilename, '] Your Github username could not be set.', gitCmd.fail]); + end + end + end + + % retrieve the user's email address + [status_gitConfEmailGet, result_gitConfEmailGet] = system('git config --get user.email'); + gitConf.userEmail = strtrim(result_gitConfEmailGet); + + if status_gitConfEmailGet == 0 + fprintf([gitCmd.lead, originCall, 'Your Github email is: ', gitConf.userEmail, '. ', gitCmd.success, gitCmd.trail]); + else + printMsg(mfilename, 'The Github email could not be retrieved.', [gitCmd.fail, gitCmd.trail]); + + % request the Github username + if isempty(gitConf.userEmail) + gitConf.userEmail = input([gitCmd.lead, originCall, ' -> Please enter your Github email: '], 's'); + + [status_gitConfEmailSet, result_gitConfEmailSet] = system(['git config --global user.email "', gitConf.userEmail, '"']); + if status_gitConfEmailSet == 0 + fprintf([gitCmd.lead, originCall, 'Your Github email is: ', gitConf.userEmail, '. ', gitCmd.success, gitCmd.trail]); + else + fprintf(result_gitConfEmailSet); + error([gitCmd.lead, ' [', mfilename, '] Your Github email could not be set.', gitCmd.fail]); + end + end + end + + % define the name of the local fork directory + gitConf.forkDirName = strrep([gitConf.leadForkDirName, gitConf.remoteRepoName], '\', '\\'); + + % retrieve the directory of the fork from the local git configuration + [~, result_gitConfForkDirGet] = system(['git config --get user.', gitConf.leadForkDirName, gitConf.nickName, '.path']); + if ~isempty(result_gitConfForkDirGet) + gitConf.fullForkDir = strtrim(result_gitConfForkDirGet); + gitConf.localDir = gitConf.fullForkDir; + else + fprintf('%s%s%s\n','Would you like to set up current directory (', currentDir, ') as a fork directory.') + gitConf.fullForkDir=currentDir; + gitConf.localDir = gitConf.fullForkDir; + end + + % check if the fork exists remotely + checkRemoteFork(); + + % request the local directory if the fullForkDir is not yet known + if isempty(gitConf.localDir) && isempty(gitConf.fullForkDir) + + createDir = false; + + while ~createDir + 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) + gitConf.localDir = strrep(pwd, '\', '\\'); + else + gitConf.localDir = reply; + end + + % strip the fork-nickName folder from the localDir if present + if ~isempty(gitConf.localDir) && length(gitConf.forkDirName) <= length(gitConf.localDir) + if strcmp(gitConf.localDir(end - length(gitConf.forkDirName) + 1:end), gitConf.forkDirName) + gitConf.localDir = gitConf.localDir(1:end - length(gitConf.forkDirName)); + end + end + + % add a fileseparator if not included + if ~strcmp(gitConf.localDir(end), filesep) + gitConf.localDir = strrep([gitConf.localDir, filesep], '\', '\\'); + end + + % warn the user of not using a fork-nickName directory or a git cloned directory as it will be cloned + if ~isempty(strfind(gitConf.localDir, gitConf.nickName)) % contains the nickname + printMsg(mfilename, ['The specified directory already contains a ', gitConf.nickName, ' copy (clone).'], gitCmd.trail); + createDir = true; + gitConf.localDir = gitConf.localDir(1:end - length(gitConf.nickName) - 1 - length(gitConf.leadForkDirName)); + + elseif exist([gitConf.localDir filesep '.git'], 'dir') == 7 % contains a .git folder + printMsg(mfilename, ['The specified directory already is a git repository (git-tracked).'], gitCmd.trail); + + else + createDir = true; + end + end + + % define the fork directory name + gitConf.fullForkDir = strrep([gitConf.localDir, gitConf.forkDirName], '\', '\\'); + + if exist(gitConf.localDir, 'dir') ~= 7 + reply = input([gitCmd.lead, originCall, ' -> The specified directory (', gitConf.localDir, ') does not exist. Do you want to create it? Y/N [Y]:'], 's'); + + % create the directory if requested + if (isempty(reply) || strcmpi(reply, 'y') || strcmpi(reply, 'yes')) && createDir + system(['mkdir ', gitConf.localDir]); + printMsg(mfilename, 'The directory has been created.'); + else + error([gitCmd.lead, ' [', mfilename, '] The specified directory does not exist.', gitCmd.fail]); + end + end + end + + resetDevToolsFlag = false; + + % permanently store the fork directory in the git configuration (ask the user explicitly) + [status_gitConfForkDirSet, result_gitConfForkDirSet] = system(['git config --global user.', gitConf.leadForkDirName, gitConf.nickName, '.path "', gitConf.fullForkDir, '"']); + if status_gitConfForkDirSet == 0 + fprintf([gitCmd.lead, originCall, 'Your fork directory has been set to: ', gitConf.fullForkDir, '. ', gitCmd.success, gitCmd.trail]); + else + fprintf(result_gitConfForkDirSet); + error([gitCmd.lead, ' [', mfilename, '] Your fork directory could not be set.', gitCmd.fail]); + end + + % clone the fork + freshClone = cloneFork(); + + % proceed with configuring the fork + configureFork(); + + % update the fork + if ~freshClone + + % change to the local fork directory + cd(gitConf.fullForkDir); + + % retrieve the status of the git repository + [status_gitStatus, result_gitStatus] = system('git status -s'); + + % only update if there are no local changes + if status_gitStatus == 0 && isempty(result_gitStatus) + updateFork(true); + else + printMsg(mfilename, 'The local fork cannot be updated as you have uncommitted changes.', [gitCmd.fail, gitCmd.trail]); + end + end + + % print the current configuration + fprintf([gitCmd.lead, originCall, ' -- Configuration -------- ', gitCmd.trail]) + fprintf([gitCmd.lead, originCall, ' GitHub username: ', gitConf.userName, gitCmd.trail]); + fprintf([gitCmd.lead, originCall, ' GitHub email: ', gitConf.userEmail, gitCmd.trail]); + fprintf([gitCmd.lead, originCall, ' Local directory : ', gitConf.fullForkDir, gitCmd.trail]) + fprintf([gitCmd.lead, originCall, ' Remote fork URL: ', gitConf.forkURL, gitCmd.trail]); + fprintf([gitCmd.lead, originCall, ' Remote repository URL: ', gitConf.remoteRepoURL, gitCmd.trail]); + +end diff --git a/src/initDevTools.m b/src/initDevTools.m index 54581ee..65c3b7d 100644 --- a/src/initDevTools.m +++ b/src/initDevTools.m @@ -98,13 +98,13 @@ function initDevTools(repoName,currentDir) % retrieve the directory of the fork from the local git configuration [~, result_gitConfForkDirGet] = system(['git config --get user.', gitConf.leadForkDirName, gitConf.nickName, '.path']); - if isempty(result_gitConfForkDirGet) - fprintf('%s%s%s\n','Attempting to progress by assuming the current directory (', currentDir, ') is a fork directory.') - gitConf.fullForkDir=currentDir; - gitConf.localDir = gitConf.fullForkDir; - else + 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 From 70c47871229ca4d97a6ea18ab7ac97458c0b1b11 Mon Sep 17 00:00:00 2001 From: WegrzynAB Date: Mon, 3 May 2021 20:50:17 +0200 Subject: [PATCH 09/15] remove autosave temp files --- src/initDevTools.asv | 212 ------------------------------------------- 1 file changed, 212 deletions(-) delete mode 100644 src/initDevTools.asv diff --git a/src/initDevTools.asv b/src/initDevTools.asv deleted file mode 100644 index 91a5c8c..0000000 --- a/src/initDevTools.asv +++ /dev/null @@ -1,212 +0,0 @@ -function initDevTools(repoName,currentDir) -% Initializes the development tools (username and email are requested if not configured) -% -% USAGE: -% -% initDevTools(repoName) -% -% INPUT: -% repoName: Name of the repository for which the devTools shall -% be configured (default: `opencobra/cobratoolbox`) -% .. Authors: -% - Laurent Heirendt, Ronan Fleming - - global gitConf - global gitCmd - global resetDevToolsFlag - global DEFAULTREPONAME - - % set the repoName if not given - if ~exist('repoName', 'var') - repoName = DEFAULTREPONAME; - end - if ~exist('currentDir', 'var') - currentDir = pwd; - end - resetDevToolsFlag = true; - - finishup = onCleanup(@() resetDevTools()); - - % check the system and set the configuration - checkSystem(mfilename, repoName); - - if ~isfield(gitConf, 'userName'), gitConf.userName = []; end - if ~isfield(gitConf, 'localDir'), gitConf.localDir = []; end - - % parse the remoteRepoURL - sepIndices = strfind(gitConf.remoteRepoURL, '/'); - gitConf.remoteServerName = gitConf.remoteRepoURL(1:sepIndices(3)); - gitConf.remoteRepoName = gitConf.remoteRepoURL(sepIndices(4) + 1:end - 4); - gitConf.remoteUserName = gitConf.remoteRepoURL(sepIndices(3) + 1:sepIndices(4) - 1); - - % ignore case for the current fork (avoids problems for untracked files with case conflicts) - [status_gitIgnoreCase, result_gitIgnoreCase] = system('git config core.ignorecase true'); - - % retrieve the user name - [status_gitConfUserGet, result_gitConfUserGet] = system('git config --get user.github-username'); - gitConf.userName = strtrim(result_gitConfUserGet); - - if gitConf.printLevel > 0 - originCall = [' [', mfilename, '] ']; - else - originCall = ''; - end - - if status_gitConfUserGet == 0 && isempty(strfind(gitConf.userName, ' ')) - fprintf([gitCmd.lead, originCall, 'Your Github username is: ', gitConf.userName, '. ', gitCmd.success, gitCmd.trail]); - else - printMsg(mfilename, 'The Github username could not be retrieved or is not valid.', [gitCmd.fail, gitCmd.trail]); - - % request the Github username if it is not known or if the username contains whitespaces - if isempty(gitConf.userName) || ~isempty(strfind(gitConf.userName, ' ')) - gitConf.userName = input([gitCmd.lead, originCall, ' -> Please enter your Github username: '], 's'); - [status_gitConfUserSet, result_gitConfUserSet] = system(['git config --global --add user.github-username "', gitConf.userName, '"']); - if status_gitConfUserSet == 0 - fprintf([gitCmd.lead, originCall, 'Your Github username is: ', gitConf.userName, '. ', gitCmd.success, gitCmd.trail]); - else - fprintf(result_gitConfUserSet); - error([gitCmd.lead, ' [', mfilename, '] Your Github username could not be set.', gitCmd.fail]); - end - end - end - - % retrieve the user's email address - [status_gitConfEmailGet, result_gitConfEmailGet] = system('git config --get user.email'); - gitConf.userEmail = strtrim(result_gitConfEmailGet); - - if status_gitConfEmailGet == 0 - fprintf([gitCmd.lead, originCall, 'Your Github email is: ', gitConf.userEmail, '. ', gitCmd.success, gitCmd.trail]); - else - printMsg(mfilename, 'The Github email could not be retrieved.', [gitCmd.fail, gitCmd.trail]); - - % request the Github username - if isempty(gitConf.userEmail) - gitConf.userEmail = input([gitCmd.lead, originCall, ' -> Please enter your Github email: '], 's'); - - [status_gitConfEmailSet, result_gitConfEmailSet] = system(['git config --global user.email "', gitConf.userEmail, '"']); - if status_gitConfEmailSet == 0 - fprintf([gitCmd.lead, originCall, 'Your Github email is: ', gitConf.userEmail, '. ', gitCmd.success, gitCmd.trail]); - else - fprintf(result_gitConfEmailSet); - error([gitCmd.lead, ' [', mfilename, '] Your Github email could not be set.', gitCmd.fail]); - end - end - end - - % define the name of the local fork directory - gitConf.forkDirName = strrep([gitConf.leadForkDirName, gitConf.remoteRepoName], '\', '\\'); - - % retrieve the directory of the fork from the local git configuration - [~, result_gitConfForkDirGet] = system(['git config --get user.', gitConf.leadForkDirName, gitConf.nickName, '.path']); - if ~isempty(result_gitConfForkDirGet) - gitConf.fullForkDir = strtrim(result_gitConfForkDirGet); - gitConf.localDir = gitConf.fullForkDir; - else - fprintf('%s%s%s\n','Would you like to set up current directory (', currentDir, ') as a fork directory.') - gitConf.fullForkDir=currentDir; - gitConf.localDir = gitConf.fullForkDir; - end - - % check if the fork exists remotely - checkRemoteFork(); - - % request the local directory if the fullForkDir is not yet known - if isempty(gitConf.localDir) && isempty(gitConf.fullForkDir) - - createDir = false; - - while ~createDir - 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) - gitConf.localDir = strrep(pwd, '\', '\\'); - else - gitConf.localDir = reply; - end - - % strip the fork-nickName folder from the localDir if present - if ~isempty(gitConf.localDir) && length(gitConf.forkDirName) <= length(gitConf.localDir) - if strcmp(gitConf.localDir(end - length(gitConf.forkDirName) + 1:end), gitConf.forkDirName) - gitConf.localDir = gitConf.localDir(1:end - length(gitConf.forkDirName)); - end - end - - % add a fileseparator if not included - if ~strcmp(gitConf.localDir(end), filesep) - gitConf.localDir = strrep([gitConf.localDir, filesep], '\', '\\'); - end - - % warn the user of not using a fork-nickName directory or a git cloned directory as it will be cloned - if ~isempty(strfind(gitConf.localDir, gitConf.nickName)) % contains the nickname - printMsg(mfilename, ['The specified directory already contains a ', gitConf.nickName, ' copy (clone).'], gitCmd.trail); - createDir = true; - gitConf.localDir = gitConf.localDir(1:end - length(gitConf.nickName) - 1 - length(gitConf.leadForkDirName)); - - elseif exist([gitConf.localDir filesep '.git'], 'dir') == 7 % contains a .git folder - printMsg(mfilename, ['The specified directory already is a git repository (git-tracked).'], gitCmd.trail); - - else - createDir = true; - end - end - - % define the fork directory name - gitConf.fullForkDir = strrep([gitConf.localDir, gitConf.forkDirName], '\', '\\'); - - if exist(gitConf.localDir, 'dir') ~= 7 - reply = input([gitCmd.lead, originCall, ' -> The specified directory (', gitConf.localDir, ') does not exist. Do you want to create it? Y/N [Y]:'], 's'); - - % create the directory if requested - if (isempty(reply) || strcmpi(reply, 'y') || strcmpi(reply, 'yes')) && createDir - system(['mkdir ', gitConf.localDir]); - printMsg(mfilename, 'The directory has been created.'); - else - error([gitCmd.lead, ' [', mfilename, '] The specified directory does not exist.', gitCmd.fail]); - end - end - end - - resetDevToolsFlag = false; - - % permanently store the fork directory in the git configuration (ask the user explicitly) - [status_gitConfForkDirSet, result_gitConfForkDirSet] = system(['git config --global user.', gitConf.leadForkDirName, gitConf.nickName, '.path "', gitConf.fullForkDir, '"']); - if status_gitConfForkDirSet == 0 - fprintf([gitCmd.lead, originCall, 'Your fork directory has been set to: ', gitConf.fullForkDir, '. ', gitCmd.success, gitCmd.trail]); - else - fprintf(result_gitConfForkDirSet); - error([gitCmd.lead, ' [', mfilename, '] Your fork directory could not be set.', gitCmd.fail]); - end - - % clone the fork - freshClone = cloneFork(); - - % proceed with configuring the fork - configureFork(); - - % update the fork - if ~freshClone - - % change to the local fork directory - cd(gitConf.fullForkDir); - - % retrieve the status of the git repository - [status_gitStatus, result_gitStatus] = system('git status -s'); - - % only update if there are no local changes - if status_gitStatus == 0 && isempty(result_gitStatus) - updateFork(true); - else - printMsg(mfilename, 'The local fork cannot be updated as you have uncommitted changes.', [gitCmd.fail, gitCmd.trail]); - end - end - - % print the current configuration - fprintf([gitCmd.lead, originCall, ' -- Configuration -------- ', gitCmd.trail]) - fprintf([gitCmd.lead, originCall, ' GitHub username: ', gitConf.userName, gitCmd.trail]); - fprintf([gitCmd.lead, originCall, ' GitHub email: ', gitConf.userEmail, gitCmd.trail]); - fprintf([gitCmd.lead, originCall, ' Local directory : ', gitConf.fullForkDir, gitCmd.trail]) - fprintf([gitCmd.lead, originCall, ' Remote fork URL: ', gitConf.forkURL, gitCmd.trail]); - fprintf([gitCmd.lead, originCall, ' Remote repository URL: ', gitConf.remoteRepoURL, gitCmd.trail]); - -end From bc2635ead989f06c920ad401d51b1b27053a5e8b Mon Sep 17 00:00:00 2001 From: WegrzynAB Date: Mon, 3 May 2021 21:12:26 +0200 Subject: [PATCH 10/15] ask if fork should be updated in the initDevTools --- src/initDevTools.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/initDevTools.m b/src/initDevTools.m index 65c3b7d..88b60a0 100644 --- a/src/initDevTools.m +++ b/src/initDevTools.m @@ -195,7 +195,14 @@ function initDevTools(repoName,currentDir) % 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 From 8ccc135132406654dd35139419cd093c752364a8 Mon Sep 17 00:00:00 2001 From: Ronan Fleming Date: Thu, 30 Sep 2021 17:48:21 +0100 Subject: [PATCH 11/15] submodules updated to master --- contribute.m | 4 ++ src/confDevTools.m | 6 +++ src/submitContribution.m | 4 +- src/updateSubmodules.m | 94 ++++++++++++++++++++++++---------------- 4 files changed, 69 insertions(+), 39 deletions(-) diff --git a/contribute.m b/contribute.m index 9dffb16..d20f90f 100644 --- a/contribute.m +++ b/contribute.m @@ -12,6 +12,10 @@ function contribute(repoName, printLevel, autoOption) % 3. Publish a branch. % 4. Delete a branch. % 5. Update the fork +% +% EXAMPLES: +% contribute('opencobra/cobratoolbox') +% contribute('opencobra/COBRA.tutorials') global gitConf global gitCmd diff --git a/src/confDevTools.m b/src/confDevTools.m index da198a6..6bdd89e 100644 --- a/src/confDevTools.m +++ b/src/confDevTools.m @@ -67,6 +67,12 @@ function confDevTools(repoName, varargin) % check if the remoteRepoURL exists before proceeding [status_curl, result_curl] = system(['curl -s -k --head ', tmpRemoteRepoURL]); + 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/submitContribution.m b/src/submitContribution.m index 0cd4f34..b40f521 100644 --- a/src/submitContribution.m +++ b/src/submitContribution.m @@ -114,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 @@ -134,7 +134,7 @@ function submitContribution(branchName) end end - %if this is an mlx file, create the mlx then add it + %if this is an mlx file, create the m file then add it if strcmp(EXT,'.mlx') mlxFile=which(fullFileName); if isempty(mlxFile) diff --git a/src/updateSubmodules.m b/src/updateSubmodules.m index 8ce009b..2f6ca68 100644 --- 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,65 @@ 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.'); - 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.'); + 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 initialized.'); 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 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.'); + else + fprintf(result_gitReset); + error([gitCmd.lead, ' [', mfilename,'] The submodules could not be reset.', gitCmd.fail]); + end + end + else + %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'); From c0c484acb0b77274354864aca0ad5990af2cc337 Mon Sep 17 00:00:00 2001 From: Ronan Fleming Date: Sun, 3 Oct 2021 11:02:20 +0100 Subject: [PATCH 12/15] print out by default --- src/checkSystem.m | 9 +++++---- src/initDevTools.m | 7 +++++-- src/updateFork.m | 4 +++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/checkSystem.m b/src/checkSystem.m index 828fcc8..cf8f249 100644 --- 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/initDevTools.m b/src/initDevTools.m index 88b60a0..0422ce7 100644 --- a/src/initDevTools.m +++ b/src/initDevTools.m @@ -1,4 +1,4 @@ -function initDevTools(repoName,currentDir) +function initDevTools(repoName,currentDir,printLevel) % Initializes the development tools (username and email are requested if not configured) % % USAGE: @@ -23,12 +23,15 @@ function initDevTools(repoName,currentDir) 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 diff --git a/src/updateFork.m b/src/updateFork.m index 8b7bee4..21e1c2d 100644 --- a/src/updateFork.m +++ b/src/updateFork.m @@ -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 From ae45060b2f2688c7e098d415eb972e851bd3d49c Mon Sep 17 00:00:00 2001 From: Ronan Fleming Date: Sun, 3 Oct 2021 22:30:48 +0100 Subject: [PATCH 13/15] att --- .gitattributes | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 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 From d9177dcd863e749670e051cf4d051f94c4336d24 Mon Sep 17 00:00:00 2001 From: Ronan Fleming Date: Thu, 3 Mar 2022 14:38:37 +0000 Subject: [PATCH 14/15] delete upstream now a warning --- src/deleteContribution.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/deleteContribution.m b/src/deleteContribution.m index f8d1613..77bfd5f 100644 --- 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 From f8bfcc8abf84133a1476f6c67b1d83011fb6ece8 Mon Sep 17 00:00:00 2001 From: rfleming Date: Fri, 27 Sep 2024 08:19:54 +0100 Subject: [PATCH 15/15] errors replaced with warnings --- .artenolis.yml | 0 .artenolis/runtests.sh | 0 .gitattributes | 0 .gitignore | 0 .gitmodules | 0 LICENSE | 0 README.rst | 0 codecov.yml | 0 contribute.m | 0 docs/.documenter.enc | 0 docs/Makefile | 0 docs/generateJSONList.py | 0 docs/requirements.txt | 0 docs/source/_static/browserconfig.xml | 0 .../source/_static/img/android-chrome-192x192.png | Bin .../source/_static/img/android-chrome-384x384.png | Bin docs/source/_static/img/apple-touch-icon.png | Bin docs/source/_static/img/favicon-16x16.png | Bin docs/source/_static/img/favicon-32x32.png | Bin docs/source/_static/img/favicon.ico | Bin docs/source/_static/img/logo_devTools.png | Bin docs/source/_static/img/mstile-150x150.png | Bin docs/source/_static/img/safari-pinned-tab.svg | 0 docs/source/_static/json/manifest.json | 0 docs/source/bestpractices.rst | 0 docs/source/cite.rst | 0 docs/source/conf.py | 0 docs/source/contents.rst | 0 docs/source/contr_cobratoolbox.rst | 0 docs/source/contr_cobratutorials.rst | 0 docs/source/contr_otherrepo.rst | 0 docs/source/contribute.rst | 0 docs/source/faq.rst | 0 docs/source/funding.rst | 0 docs/source/getstarted.rst | 0 docs/source/index.rst | 0 docs/source/installation.rst | 0 docs/source/modules/index.rst | 0 docs/source/prerequisites.rst | 0 docs/source/sphinxext/__init__.py | 0 docs/source/sphinxext/github_linkcode.py | 0 docs/source/troubleshooting.rst | 0 docs/source/troubleshooting/cobratoolbox.rst | 0 docs/source/troubleshooting/cobratutorials.rst | 0 src/addKeyToKnownHosts.m | 0 src/checkBranchExistence.m | 0 src/checkDevTools.m | 0 src/checkLocalFork.m | 0 src/checkRemoteBranchExistence.m | 0 src/checkRemoteFork.m | 0 src/checkStatus.m | 0 src/checkSystem.m | 0 src/checkoutBranch.m | 0 src/cloneFork.m | 0 src/confDevTools.m | 0 src/configureFork.m | 0 src/deleteContribution.m | 0 src/getCurrentBranchName.m | 0 src/history.m | 0 src/initContribution.m | 0 src/initDevTools.m | 0 src/listBranches.m | 0 src/matlab/m2mlx.m | 0 src/matlab/mlx2m.m | 0 src/openPR.m | 0 src/printMsg.m | 0 src/resetDevTools.m | 0 src/resetLocalFork.m | 0 src/submitContribution.m | 0 src/updateDevTools.m | 0 src/updateFork.m | 0 src/updateSubmodules.m | 14 ++++++++++++-- test/inputCI.txt | 0 test/launchTests.m | 0 test/testCheckSystem.m | 0 75 files changed, 12 insertions(+), 2 deletions(-) mode change 100644 => 100755 .artenolis.yml mode change 100644 => 100755 .artenolis/runtests.sh mode change 100644 => 100755 .gitattributes mode change 100644 => 100755 .gitignore mode change 100644 => 100755 .gitmodules mode change 100644 => 100755 LICENSE mode change 100644 => 100755 README.rst mode change 100644 => 100755 codecov.yml mode change 100644 => 100755 contribute.m mode change 100644 => 100755 docs/.documenter.enc mode change 100644 => 100755 docs/Makefile mode change 100644 => 100755 docs/generateJSONList.py mode change 100644 => 100755 docs/requirements.txt mode change 100644 => 100755 docs/source/_static/browserconfig.xml mode change 100644 => 100755 docs/source/_static/img/android-chrome-192x192.png mode change 100644 => 100755 docs/source/_static/img/android-chrome-384x384.png mode change 100644 => 100755 docs/source/_static/img/apple-touch-icon.png mode change 100644 => 100755 docs/source/_static/img/favicon-16x16.png mode change 100644 => 100755 docs/source/_static/img/favicon-32x32.png mode change 100644 => 100755 docs/source/_static/img/favicon.ico mode change 100644 => 100755 docs/source/_static/img/logo_devTools.png mode change 100644 => 100755 docs/source/_static/img/mstile-150x150.png mode change 100644 => 100755 docs/source/_static/img/safari-pinned-tab.svg mode change 100644 => 100755 docs/source/_static/json/manifest.json mode change 100644 => 100755 docs/source/bestpractices.rst mode change 100644 => 100755 docs/source/cite.rst mode change 100644 => 100755 docs/source/conf.py mode change 100644 => 100755 docs/source/contents.rst mode change 100644 => 100755 docs/source/contr_cobratoolbox.rst mode change 100644 => 100755 docs/source/contr_cobratutorials.rst mode change 100644 => 100755 docs/source/contr_otherrepo.rst mode change 100644 => 100755 docs/source/contribute.rst mode change 100644 => 100755 docs/source/faq.rst mode change 100644 => 100755 docs/source/funding.rst mode change 100644 => 100755 docs/source/getstarted.rst mode change 100644 => 100755 docs/source/index.rst mode change 100644 => 100755 docs/source/installation.rst mode change 100644 => 100755 docs/source/modules/index.rst mode change 100644 => 100755 docs/source/prerequisites.rst mode change 100644 => 100755 docs/source/sphinxext/__init__.py mode change 100644 => 100755 docs/source/sphinxext/github_linkcode.py mode change 100644 => 100755 docs/source/troubleshooting.rst mode change 100644 => 100755 docs/source/troubleshooting/cobratoolbox.rst mode change 100644 => 100755 docs/source/troubleshooting/cobratutorials.rst mode change 100644 => 100755 src/addKeyToKnownHosts.m mode change 100644 => 100755 src/checkBranchExistence.m mode change 100644 => 100755 src/checkDevTools.m mode change 100644 => 100755 src/checkLocalFork.m mode change 100644 => 100755 src/checkRemoteBranchExistence.m mode change 100644 => 100755 src/checkRemoteFork.m mode change 100644 => 100755 src/checkStatus.m mode change 100644 => 100755 src/checkSystem.m mode change 100644 => 100755 src/checkoutBranch.m mode change 100644 => 100755 src/cloneFork.m mode change 100644 => 100755 src/confDevTools.m mode change 100644 => 100755 src/configureFork.m mode change 100644 => 100755 src/deleteContribution.m mode change 100644 => 100755 src/getCurrentBranchName.m mode change 100644 => 100755 src/history.m mode change 100644 => 100755 src/initContribution.m mode change 100644 => 100755 src/initDevTools.m mode change 100644 => 100755 src/listBranches.m mode change 100644 => 100755 src/matlab/m2mlx.m mode change 100644 => 100755 src/matlab/mlx2m.m mode change 100644 => 100755 src/openPR.m mode change 100644 => 100755 src/printMsg.m mode change 100644 => 100755 src/resetDevTools.m mode change 100644 => 100755 src/resetLocalFork.m mode change 100644 => 100755 src/submitContribution.m mode change 100644 => 100755 src/updateDevTools.m mode change 100644 => 100755 src/updateFork.m mode change 100644 => 100755 src/updateSubmodules.m mode change 100644 => 100755 test/inputCI.txt mode change 100644 => 100755 test/launchTests.m mode change 100644 => 100755 test/testCheckSystem.m 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 old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.gitmodules b/.gitmodules old mode 100644 new mode 100755 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 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 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/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 diff --git a/src/checkRemoteFork.m b/src/checkRemoteFork.m old mode 100644 new mode 100755 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 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 diff --git a/src/configureFork.m b/src/configureFork.m old mode 100644 new mode 100755 diff --git a/src/deleteContribution.m b/src/deleteContribution.m old mode 100644 new mode 100755 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 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 old mode 100644 new mode 100755 diff --git a/src/matlab/mlx2m.m b/src/matlab/mlx2m.m old mode 100644 new mode 100755 diff --git a/src/openPR.m b/src/openPR.m old mode 100644 new mode 100755 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 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 diff --git a/src/updateSubmodules.m b/src/updateSubmodules.m old mode 100644 new mode 100755 index 2f6ca68..dc55f8a --- a/src/updateSubmodules.m +++ b/src/updateSubmodules.m @@ -58,10 +58,10 @@ function updateSubmodules() [status_gitSubmodule, result_gitSubmodule] = system('git submodule update'); if status_gitSubmodule == 0 - printMsg(mfilename, 'The submodules have been initialized.'); + printMsg(mfilename, 'The submodules have been updated.'); else fprintf(result_gitSubmodule); - error([gitCmd.lead, ' [', mfilename,'] The submodules could not be initialized.', gitCmd.fail]); + error([gitCmd.lead, ' [', mfilename,'] The submodules could not be updated.', gitCmd.fail]); end % update the submodules @@ -76,6 +76,16 @@ function updateSubmodules() end end else + % 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 + %Check for changes to submodules [status_gitSubmodule, result_gitSubmodule] = system('git submodule foreach git status'); if status_gitSubmodule==0 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