diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..f5bb9ed --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "external/rdir"] + path = external/rdir + url = https://github.com/uni-lu/rdir.git diff --git a/README.rst b/README.rst index 5a1e307..fc16ebe 100644 --- a/README.rst +++ b/README.rst @@ -97,10 +97,10 @@ You will then be presented by a menu: :: - [1] Start a new feature (branch). - [2] Select an existing feature (branch) to work on. - [3] Publish a feature (branch). - [4] Delete a feature (branch). + [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. -> Please select what you want to do (enter the number): diff --git a/contribute.m b/contribute.m index af50fc7..75ef232 100644 --- a/contribute.m +++ b/contribute.m @@ -1,17 +1,20 @@ -function contribute(repoName, printLevel) +function contribute(repoName, printLevel, autoOption) % devTools % % PURPOSE: displays a menu and calls the respective subfunctions % -% 1. Start a new feature (branch): -% 2. Select an existing feature (branch) to work on. -% 3. Publish a feature (branch). -% 4. Delete a feature (branch). +% 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 global gitConf global gitCmd @@ -26,14 +29,24 @@ function contribute(repoName, printLevel) % adding the src folder of the devTools addpath(genpath(fileparts(which(mfilename)))); + % check the automatic option argument + autoOptionFlag = false; + if exist('autoOption', 'var') + if ~isempty(autoOption) && autoOption > 0 && autoOption < 6 + autoOptionFlag = true; + else + error('Please enter an automatic menu option between 1 and 5.') + end + end + % treatment of input arguments - if ~exist('repoName', 'var') + if ~exist('repoName', 'var') || isempty(repoName) DEFAULTREPONAME = 'opencobra/cobratoolbox'; % set the default repository repoName = DEFAULTREPONAME; end % soft reset if the repository name is different - if ~isempty(gitConf) + if ~isempty(gitConf) && exist('repoName', 'var') && isfield(gitConf, 'remoteUserName') && isfield(gitConf, 'remoteRepoName') if ~strcmpi(repoName, [gitConf.remoteUserName '/' gitConf.remoteRepoName]) resetDevTools(); end @@ -46,8 +59,10 @@ function contribute(repoName, printLevel) checkSystem(mfilename, repoName); end + % perform a soft reset if interrupted finishup = onCleanup(@() resetDevTools()); + % determine the directory of the devTools devToolsDir = fileparts(which(mfilename)); % change to the directory of the devTools @@ -56,23 +71,29 @@ function contribute(repoName, printLevel) % update the devTools updateDevTools(); + % print the launcher fprintf(gitConf.launcher); - choice = input('\n (You can abort any process using CTRL+C)\n\n [1] Start a new feature (branch).\n [2] Select an existing feature (branch) to work on.\n [3] Publish a feature (branch).\n [4] Delete a feature (branch).\n [5] Update the fork.\n\n -> Please select what you want to do (enter the number): ', 's'); - - choice = str2num(choice); + % show the menu to select an option + if autoOptionFlag + choice = autoOption; + else + choice = input('\n (You can abort any process using CTRL+C)\n\n [1] Start a new branch.\n [2] Select an existing branch to work on.\n [3] Publish a branch.\n [4] Delete a branch.\n [5] Update the fork.\n\n -> Please select what you want to do (enter the number): ', 's'); + choice = str2num(choice); + end + % evaluate the option if length(choice) == 0 || choice > 5 || choice < 0 error('Please enter a number between 1 and 5.') else if ~isempty(choice) && length(choice) > 0 - % ask for a name of the feature/branch + % ask for a name of the branch if choice == 1 - % list the available features if the fork is already configured + % list the available branches if the fork is already configured if exist('gitConf.fullForkDir', 'var') - %list all available features - listFeatures(); + %list all available branches + listBranches(); end % define a name of an example branch @@ -80,7 +101,7 @@ function contribute(repoName, printLevel) reply = ''; while isempty(reply) - reply = input([' -> Please enter a name of the new feature (branch) that you want to work on (example: ', exampleBranch, '): '], 's'); + reply = input([' -> Please enter a name of the new branch that you want to work on (example: ', exampleBranch, '): '], 's'); if ~isempty(strfind(reply, 'develop')) || ~isempty(strfind(reply, 'master')) reply = ''; fprintf([gitCmd.lead, 'Please use a different name that does not contain or .', gitCmd.fail, gitCmd.trail]); @@ -94,8 +115,8 @@ function contribute(repoName, printLevel) % change to the fork diretory cd(gitConf.fullForkDir); - %list all available features - [exitFlag, currentBranch, ~, exampleBranch] = listFeatures(); + %list all available branches + [exitFlag, currentBranch, ~, exampleBranch] = listBranches(); if ~strcmpi('develop', currentBranch) && ~strcmpi('master', currentBranch) exampleBranch = currentBranch; @@ -105,22 +126,22 @@ function contribute(repoName, printLevel) reply = ''; if choice == 2 while isempty(reply) && ~exitFlag - reply = input([' -> Please enter the name of the existing feature (branch) that you want to work on (example: ', exampleBranch, '): '], 's'); + reply = input([' -> Please enter the name of the existing branch that you want to work on (example: ', exampleBranch, '): '], 's'); end elseif choice == 3 while isempty(reply) - reply = input([' -> Please enter the name of the feature (branch) that you want to publish (example: ', exampleBranch, '): '], 's'); + reply = input([' -> Please enter the name of the branch that you want to publish (example: ', exampleBranch, '): '], 's'); end elseif choice == 4 - % list the available features if the fork is already configured + % list the available branches if the fork is already configured if exist('gitConf.fullForkDir', 'var') - %list all available features - listFeatures(); + %list all available branches + listBranches(); end while isempty(reply) - reply = input([' -> Please enter the name of the feature (branch) that you want to delete (example: ', exampleBranch, '): '], 's'); + reply = input([' -> Please enter the name of the branch that you want to delete (example: ', exampleBranch, '): '], 's'); end end end diff --git a/docs/source/bestpractices.rst b/docs/source/bestpractices.rst new file mode 100644 index 0000000..ea05e66 --- /dev/null +++ b/docs/source/bestpractices.rst @@ -0,0 +1,21 @@ +.. _bestpractices: + +Best practices +============== + +Naming a contribution +--------------------- + +Initiate a contribution per theme/topic/feature/bug fix that you work +on. Don’t mix features and think of an explicit name, i.e. +``bug-fix-function1`` or ``add-tests-function2``. Avoid generic names, +such as ``my-great-feature`` or ``fix`` or ``contribution-myName``. + +Submitting a Pull Request (PR) +------------------------------ + +Once you submit your contribution (menu option [3]), you will be +presented with a link that leads you directly to the pull request (PR). +Once the PR is submitted, wait until it is reviewed and accepted. +Once merged, please start a new branch by running ``contribute`` and +selecting [1] after your pull request has been reviewed and merged. diff --git a/docs/source/contents.rst b/docs/source/contents.rst index 7da0986..4350f13 100644 --- a/docs/source/contents.rst +++ b/docs/source/contents.rst @@ -8,6 +8,7 @@ MATLAB.devTools installation getstarted contribute + bestpractices modules/index faq troubleshooting diff --git a/docs/source/contr_cobratoolbox.rst b/docs/source/contr_cobratoolbox.rst index fa53b5b..4614310 100644 --- a/docs/source/contr_cobratoolbox.rst +++ b/docs/source/contr_cobratoolbox.rst @@ -12,7 +12,7 @@ Introduction A comprehensive code base such as the COBRA Toolbox evolves constantly. The open-source community is very active, and collaborators submit their -contributions frequently. The more a new feature or bug fix is interlinked with +contributions frequently. The more a change to code or bug fix is interlinked with existing functions, the higher the risk of a new addition breaking instantly code that is heavily used on a daily basis. In order to decrease this risk, a continuous integration setup interlinked with the version control system git @@ -22,8 +22,7 @@ other documents of which all incremental changes are tracked by date and user. Any incremental changes to the code are called commits. The main advantage of git over other version control systems is the availability of branches. In simple terms, a branch contains a sequence of incremental changes to the code. -A branch is also commonly referred to as a feature. Consequently, a -contribution generally consists of several commits on a branch. +Consequently, a contribution generally consists of several commits on a branch. Contributing to the COBRA Toolbox is straightforward. As a contributor to the COBRA Toolbox is likely more familiar with MATLAB than with the internal @@ -170,12 +169,12 @@ Deleting a contribution ----------------------- If a contribution has been merged into the develop branch of the opencobra -repository (accepted pull request), the contribution (feature or branch) can be +repository (accepted pull request), the contribution (branch) can be safely deleted both locally and remotely on the fork by running contribute and selecting procedure ``[4]``. Note that deleting a contribution deletes all the changes that have been made -on that feature (branch). It is not possible to selectively delete a commit +on that branch. It is not possible to selectively delete a commit using the MATLAB.devTools. Instead, create a new branch by following procedure ``[1]``, and follow the instructions to cherry-pick (see :ref:`troubleshooting`). diff --git a/docs/source/faq.rst b/docs/source/faq.rst index 2cf3c72..b142b05 100644 --- a/docs/source/faq.rst +++ b/docs/source/faq.rst @@ -6,14 +6,6 @@ Frequently Asked Questions (FAQ) General questions ----------------- -How should I name my contribution? -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Initiate a contribution per theme/topic/feature/bug fix that you work -on. Don’t mix features and think of an explicit name, i.e. -``bug-fix-function1`` or ``add-tests-function2``. Avoid generic names, -such as ``my-great-feature`` or ``fix`` or ``contribution-myName``. - How can I check the history of a file? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,12 +15,6 @@ You can check the history of a file by typing in MATLAB: >> history('fileName.m') -How do I submit a Pull Request (PR)? -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Once you submit your contribution (menu option [3]), you will be -presented with a link that leads you directly to the pull request (PR). - Print more detailed debugging information (verbose) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -62,7 +48,7 @@ You may encounter the following error: This error can have multiple reasons, but most likely, the SSH key is not configured properly. Please follow the `configuration -instructions `__ +instructions `__ carefully. Another source of this error may be that you have set a passphrase when diff --git a/docs/source/troubleshooting/cobratoolbox.rst b/docs/source/troubleshooting/cobratoolbox.rst index ff51612..eb318d6 100644 --- a/docs/source/troubleshooting/cobratoolbox.rst +++ b/docs/source/troubleshooting/cobratoolbox.rst @@ -23,10 +23,10 @@ COBRA Toolbox are consequently commits that are made on branches. The development scheme adopted in the repository of the COBRA Toolbox has two branches: a `master` and a `develop` branch. The stable branch is the `master` -branch, while it is the `develop` branch that includes all new features and to +branch, while it is the `develop` branch that includes all new changes to code and to which new contributions are merged. Contributions are submitted for review and testing through pull requests, the `git` standard. The `develop` branch is -regularly merged into the `master` branch once testing is concluded. +regularly merged into the `master` branch once testing is concluded. The development scheme has been adopted for obvious reasons: the COBRA Toolbox is heavily used on a daily basis, while the development community is active. @@ -55,7 +55,7 @@ This will create a folder called fork-cobratoolbox. Make sure to replace to be run from within the folder of the fork called `fork-cobratoolbox`. .. code:: console - + $ cd fork-cobratoolbox In order to complete the cloned repository with external code, it is @@ -125,7 +125,7 @@ contribution. A new contribution must be made on a new branch, that originates from the `develop` branch. Create the new branch: .. code:: console - + $ git checkout -b develop Now, you can make changes in the folder `fork-cobratoolbox`. Once you are done @@ -145,29 +145,29 @@ adding the file: |warning| Contrary to what is sometimes provided as a shortcut, it is not advised to add all files all at once using as this command will add all files, -even hidden files and binaries. +even hidden files and binaries. .. code:: console - $ git add . # bad practice + $ git add . # bad practice -Then, commit the changes by setting a commit message : +Then, commit the changes by setting a commit message : .. code:: console $ git commit -m "" -Finally, push your commit to Github: +Finally, push your commit to Github: .. code:: console - $ git push origin + $ git push origin You should then see your commit online, and if ready, you can open a pull request. You can select your branch in the dropdown menu and list all commits by clicking on `commits`. -Continue working on your branch after a while (rebase) +Continue working on your branch after a while (rebase) ------------------------------------------------------ If there have been major changes or if you want to continue working on a branch @@ -177,7 +177,7 @@ from the upstream repository. Before doing so, make sure that you do not have any uncommitted or local changes (git status). .. code:: console - + $ git checkout develop $ git fetch upstream $ git merge upstream/develop @@ -191,7 +191,7 @@ use a merge tool such as `kdiff3`. In order to install a merge tool or abort the rebase process, type: .. code:: console - + $ git rebase --abort In order to have the changes on `` reflected in the online @@ -199,10 +199,10 @@ repository, push the changes with force. Pushing with force is required as the history of the branch has been rewritten during rebase. .. code:: console - + $ git push --force -Selectively use a commit on your branch (cherry-pick) +Selectively use a commit on your branch (cherry-pick) ----------------------------------------------------- Imagine having two branches called `` and ``. On branch @@ -210,7 +210,7 @@ Imagine having two branches called `` and ``. On branch cherry-pick the commit from `` to `` by typing: .. code:: console - + $ git checkout myBranch-2 $ git cherry-pick SHA1 @@ -219,6 +219,6 @@ message and author information. In order to have the commit listed online, conclude the cherry-pick by pushing the commit to the remote repository: .. code:: console - + $ git push myBranch-2 diff --git a/external/rdir b/external/rdir new file mode 160000 index 0000000..0bfa4a3 --- /dev/null +++ b/external/rdir @@ -0,0 +1 @@ +Subproject commit 0bfa4a3b623bf3cdfa1e707c4932c47d1035c5f3 diff --git a/external/rdir/enhanced_rdir.m b/external/rdir/enhanced_rdir.m deleted file mode 100755 index 9ee8257..0000000 --- a/external/rdir/enhanced_rdir.m +++ /dev/null @@ -1,65 +0,0 @@ -%% RDIR Enhanced - Examples of use -% -% This script demonstrates how to use the different abilities of the -% enhanced |rdir| function. -% -% Examples are based on |matlabroot| directory content. Results may vary -% depending on your version of Matlab. -% - -%% Standard use -rdir([matlabroot, '\*.txt']) - -%% Using double wildcard ** -% List |".m"| files whose name contains |"tmpl"| in all subdirectories of -% |matlabroot| -rdir([matlabroot, '\**\*tmpl*.m']) - -%% RDIR output -d = rdir([matlabroot, '\**\*tmpl*.m']) - -%% -disp(d(1)) - - -%% Using 3rd argument to shorten output names -% Remove |"C:\Program Files\"| in returned names -rdir([matlabroot, '\*.txt'], '', 'C:\Program Files\') - -%% -% Remove |matlabroot| in returned names -rdir([matlabroot, '\*.txt'], '', true) - -%% -% Optional 2nd |rdir| output indicates common path removed from each output -% name -[d, p] = rdir([matlabroot, '\*.txt'], '', true); - -fprintf('Common path : \n%s\n\n', p) - -disp( d(1) ) - -%% Using a filter with "regexp" -% List |".mat"| files, then select those whose name match regular expression -% |'data\d'| (ie |"data"| followed by a numeric digit) -rdir([matlabroot '\toolbox\**\*.mat'], 'regexp(name, ''data\d'')', true) - -%% Using a function handle as filter - -fun = @(d) ~isempty(regexp(d.name, 'data\d')) && (d.bytes < 10*1024) - -rdir([matlabroot '\toolbox\**\*.mat'], fun, true) - -%% Specific display - No item matching filter -% When some items match input path, but none match filter, a specific -% message is displayed. -rdir(matlabroot, 'strcmp(name, ''unknowtoolbox'')', 1) - - -%% Specific display - Wrong filter -% A warning is displayed after the non-filtered result list if entered -% filter is wrong. -rdir(matlabroot, 'wrong filter', 1) - - -% EOF diff --git a/external/rdir/license.txt b/external/rdir/license.txt deleted file mode 100644 index 1753a7d..0000000 --- a/external/rdir/license.txt +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2014, Thomas Vanaret -Copyright (c) 2009, Gus Brown -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the distribution - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. diff --git a/external/rdir/rdir.m b/external/rdir/rdir.m deleted file mode 100755 index f0c623d..0000000 --- a/external/rdir/rdir.m +++ /dev/null @@ -1,438 +0,0 @@ -function [varargout] = rdir(rootdir,varargin) -% RDIR - Recursive directory listing -% -% D = rdir(ROOT) -% D = rdir(ROOT, TEST) -% D = rdir(ROOT, TEST, RMPATH) -% D = rdir(ROOT, TEST, 1) -% D = rdir(ROOT, '', ...) -% [D, P] = rdir(...) -% rdir(...) -% -% -% *Inputs* -% -% * ROOT -% -% rdir(ROOT) lists the specified files. -% ROOT can be a pathname, filename, or can include both. One can use -% absolute and relative pathnames and wildcards (*). Wildcard can be placed -% anywhere and used many times like 'path*\*.m' -% -% One can also use a double wildcard (**) to match multiple directory -% levels. For example ROOT = 'path\**\*.m' will match all ".m" files in -% "path" and all subdirectories of "path". -% -% NOTE : ".svn" directories created by SubVersion (SVN) are excluded from -% the recursive listing. -% -% * TEST -% -% Optional test that can be performed on the returned files. -% -% TEST is a string indicating expression to be evaluated on selected field -% of rdir output. -% All fields (ie name, date, bytes, isdir and datenum) can be used. -% -% Tests are strings similar to what one would use in a "if" statement e.g. -% 'bytes>1024 & datenum>now-7' -% -% One can also use function like "regexp" or "strfind" with string fields -% like "name" and "date" e.g 'regexp(name, 'expr')'. In that case, tests -% that return a non empty value are considered as true. -% -% regexp(name, '(\.m$)|(\.mdl$)') -% -% Test can also be a function handle as used in arrayfun/cellfun, e.g. -% @(f)f.bytes>1024 -% -% * RMPATH -% -% Optional path to remove from beginning of "name" field in returned -% output. Specified path must be common to all items found. -% -% If RMPATH = 1 or true, path to remove is part of ROOT before the first -% wildcard. -% -% -% *Outputs* -% -% * D -% -% D is a structure with the same fields as Matlab DIR output. -% -% The "name" field includes the relative path as well as the name to the -% file that was found. Path can be shorten or ommited when using 3rd -% argument RMPATH. -% -% * P -% -% Common path or RMPATH (if specified) for the file list returned in D. -% -% * Screen output -% -% If not output variable is specified then the output is sent to the -% screen. -% -% -% *Versions* -% -% * 1.0 - 2009, Gus Brown -% * 2.0 - 26/05/2011 Thomas Vanaret -% No longer exclude all directories from a simple search (no *); -% Fixing bug on returned path; -% Exclude ".svn" directories; -% Extended test possibilies; -% Subfunctions created; -% * 2.1 - 14/07/2011 Thomas Vanaret -% New argument allowing to remove common path from name; -% Comments review; -% * 2.2 - 20/12/2011 Thomas Vanaret -% Fixing bug on display with 0b files; -% Specific display when no file match filter; -% * 2.3 - 19/01/2014 Thomas Vanaret -% Adding improvements suggested by X. Mo : -% - function handle as TEST input -% - code optimisation (avoiding loop) -% Fixing possible bug when using a wildcard at the beginning; -% Common path as 2nd optionnal output; -% -% -% *Examples* -% -% D = rdir('*.m'); -% for ii=1:length(D), disp(D(ii).name); end; -% -% % to find all files in the current directory and sub directories -% D = rdir('**\*') -% -% % If no output is specified then the files are sent to -% % the screen. -% rdir('c:\program files\windows *\*.exe'); -% rdir('c:\program files\windows *\**\*.dll'); -% -% % Using the test function to find files modified today -% rdir('c:\win*\*','datenum>floor(now)'); -% % Using the test function to find files of a certain size -% rdir('c:\program files\win*\*.exe','bytes>1024 & bytes<1048576'); -% % Using the test function to find files modified in 2011 -% rdir('c:\win*\*','strfind(date, ''2011'')'); -% -% % Using the 3rd input to shorten output name -% rdir([matlabroot, '\*.txt'], '', 'C:\Program Files\') -% % Using the 3rd input to shorten output name -% rdir([matlabroot, '\*.txt'], '', 1) -% -% -% See also DIR -% - - -%-------------------------------------------------------------------------- -%% Input validation - -% use the current directory if nothing is specified -if ~exist('rootdir','var'), - rootdir = '*'; -end - -prepath = ''; % the path before the wild card -wildpath = ''; % the path wild card -postpath = rootdir; % the path after the wild card -I = find(rootdir==filesep,1,'last'); - -% Directory separator for current platform -if filesep == '\' - % On PC, filesep is '\' - anti_filesep = '/'; -else - % On UNIX system, filesep is '/' - anti_filesep = '\'; -end - -if isempty(I) && ~isempty(strfind(rootdir, anti_filesep)) - error([mfilename, ':FileSep'],... - 'Use correct directory separator "%s".', filesep) -end - - -%-------------------------------------------------------------------------- -%% Split rootdir -% split the file path around the wild card specifiers - -if ~isempty(I), - prepath = rootdir(1:I); - postpath = rootdir(I+1:end); - I = find(prepath=='*',1,'first'); - if ~isempty(I), - postpath = [prepath(I:end) postpath]; - prepath = prepath(1:I-1); - I = find(prepath==filesep,1,'last'); - if ~isempty(I), - wildpath = prepath(I+1:end); - prepath = prepath(1:I); - end; - I = find(postpath==filesep,1,'first'); - if ~isempty(I), - wildpath = [wildpath postpath(1:I-1)]; - postpath = postpath(I:end); - end; - end; -end; - -% disp([' "' prepath '" ~ "' wildpath '" ~ "' postpath '" ']); - -%-------------------------------------------------------------------------- -%% Recursive listing -% Search for matching files until all wildcards have been considered. - -if isempty(wildpath) - % If no directory wildcards then just get files and directories list - - D = dir([prepath postpath]); - - % Exclude ".", ".." and ".svn" directories from the list - excl = isdotdir(D) | issvndir(D); - D(excl) = []; - - if isdir([prepath postpath]); - fullpath = [prepath postpath]; - else - fullpath = prepath; - end - - % Place directories on the top of the list - is_dir = [D.isdir]'; - D = [D(is_dir); D(~is_dir)]; - - % Add path before name - for ii = 1:length(D) - D(ii).name = fullfile(fullpath, D(ii).name); - end - - % disp(sprintf('Scanning "%s" %g files found',[prepath postpath],length(D))); - -elseif strcmp(wildpath,'**') - % A double wildcards directory means recurs down into sub directories - - % first look for files in the current directory (remove extra filesep) - D = rdir([prepath postpath(2:end)]); - - % then look for sub directories - D_sd = dir([prepath '*']); - - % Exclude ".", "..", ".svn" directories and files from the list - excl = isdotdir(D_sd) | issvndir(D_sd) | ~([D_sd.isdir]'); - D_sd(excl) = []; - - % Process each sub directory found - % Performance tweak: avoid growing array within loop (X. Mo) - c_D = arrayfun(@(x) rdir([prepath x.name filesep wildpath postpath]),... - D_sd, 'UniformOutput', false); - - D = [D; cell2mat( c_D ) ]; - -else - % Process directory wild card looking for sub directories that match - - D_sd = dir([prepath wildpath]); - - % Exclude ".", "..", ".svn" directories and files from the list - excl = isdotdir(D_sd) | issvndir(D_sd) | ~([D_sd.isdir]'); - D_sd(excl) = []; - - if ~isdir(prepath) || ( numel(D_sd)==1 && strcmp(D_sd.name, prepath)) - % Fix case like rdir('path*\...') where prepath is not a full directoty - % name OR case were prepath match a unique directory. - % Previous "dir" return then the matching directory name(s). - % prepath is cleaned to use them. - % - % In else case, prepath is a valid path which must be kept. - prepath = ''; - end - - % Process each directory found - Dt = dir(''); - - c_D = arrayfun(@(x) rdir([prepath x.name postpath]),... - D_sd, 'UniformOutput', false); - - D = [Dt; cell2mat( c_D ) ]; - -end - - -%-------------------------------------------------------------------------- -%% Apply filter -% If specified, apply the filter to refine the search. - -nb_before_filt = length(D); -warning_msg = ''; - -if (nargin>=2 && ~isempty(varargin{1})), - try - if isa(varargin{1}, 'function_handle') - test_tf = arrayfun(varargin{1}, D); - else - test_tf = evaluate(D, varargin{1}); - end - - D = D(test_tf); - - catch - if isa(varargin{1}, 'function_handle') - test_expr = func2str(varargin{1}); - else - test_expr = varargin{1}; - end - - warning_msg = sprintf('Invalid TEST "%s" : %s', test_expr, lasterr); - end -end - - -%-------------------------------------------------------------------------- -%% Remove path -% If specified, remove given or common path from each returned path. - -common_path = ''; -if (nargin>=3 && ~isempty(varargin{2})), - - arg2 = varargin{2}; - if ischar(arg2) - common_path = arg2; - elseif (isnumeric(arg2) || islogical(arg2)) && arg2 - common_path = prepath; - end - - rm_path = regexptranslate('escape', common_path); - - % Check that path is common to all - start = regexp({D.name}', ['^', rm_path]); - - % Convert to a logical. - is_common = not( cellfun(@isempty, start) ); - - if all(is_common) - for k = 1:length(D) - D(k).name = regexprep(D(k).name, ['^', rm_path], ''); - end - - else - common_path = ''; - end - - % 19/07/2012 : ajouter common_path en sortie optionnelle - -end - - -%-------------------------------------------------------------------------- -%% Display listing if no output variables are specified -% Screen display. - -nout = nargout; - -if nout == 0 - if isempty(D) - if nb_before_filt == 0 - fprintf('%s not found.\n', rootdir) - else - fprintf('No item matching filter.\n') - end - else - - if ~isempty(common_path) - fprintf('All in : %s\n', common_path) - end - - pp = {'' 'k' 'M' 'G' 'T'}; - for ii = 1:length(D) - if D(ii).isdir - % Directory item : display name - disp(sprintf(' %29s %-64s','',D(ii).name)); - else - % File item : display size, modification date and name - sz = D(ii).bytes; - if sz > 0 - ss = min(4,floor(log2(sz)/10)); - else - ss = 0; - end - disp(sprintf('%4.0f %1sb %20s %-64s ',... - sz/1024^ss, pp{ss+1}, datestr(D(ii).datenum, 0), D(ii).name)); - end - end - end -elseif nout == 1 - % send list out - varargout{1} = D; -else - % send list and common path out - varargout{1} = D; - varargout{2} = common_path; -end; - -if ~isempty(warning_msg) - warning([mfilename, ':InvalidTest'],... - warning_msg); % ap aff -end - -%---------------------------- end of main function ------------------------ - - -%% ------------------------------------------------------------------------ -function tf = issvndir(d) -% True for ".svn" directories. -% d is a structure returned by "dir" -% - -is_dir = [d.isdir]'; - -is_svn = strcmp({d.name}, '.svn')'; -%is_svn = false; % uncomment to disable ".svn" filtering - -tf = (is_dir & is_svn); - -%---------------------------- end of subfunction -------------------------- - -%% ------------------------------------------------------------------------ -function tf = isdotdir(d) -% True for "." and ".." directories. -% d is a structure returned by "dir" -% - -is_dir = [d.isdir]'; - -is_dot = strcmp({d.name}, '.')'; -is_dotdot = strcmp({d.name}, '..')'; - -tf = (is_dir & (is_dot | is_dotdot) ); - -%---------------------------- end of subfunction -------------------------- - -%% ------------------------------------------------------------------------ -function tf = evaluate(d, expr) -% True for item where evaluated expression is correct or return a non empty -% cell. -% d is a structure returned by "dir" -% - -% Get fields that can be used -name = {d.name}'; %#ok -date = {d.date}'; %#ok -datenum = [d.datenum]'; %#ok -bytes = [d.bytes]'; %#ok -isdir = [d.isdir]'; %#ok - -tf = eval(expr); % low risk since done in a dedicated subfunction. - -% Convert cell outputs returned by "strfind" or "regexp" filters to a -% logical. -if iscell(tf) - tf = not( cellfun(@isempty, tf) ); -end - -%---------------------------- end of subfunction -------------------------- - -%---------------------------- END OF FUNCTION ----------------------------- diff --git a/src/checkoutBranch.m b/src/checkoutBranch.m index 18cab37..c2f7405 100644 --- a/src/checkoutBranch.m +++ b/src/checkoutBranch.m @@ -48,7 +48,7 @@ function checkoutBranch(branchName, updateForkFlag) if status_gitBranch == 0 && ~strcmpi(mainBranch, currentBranch) && isempty(result_gitStatus) && status_gitStatus == 0 - printMsg(mfilename, ['The current feature (branch) ', currentBranch, ' is not the <' mainBranch '> feature (branch).'], [gitCmd.fail, gitCmd.trail]); + printMsg(mfilename, ['The current branch ', currentBranch, ' is not the <' mainBranch '> branch.'], [gitCmd.fail, gitCmd.trail]); % update the fork locally if updateForkFlag @@ -62,21 +62,21 @@ function checkoutBranch(branchName, updateForkFlag) currentBranch = getCurrentBranchName(); if status_gitCheckout == 0 && strcmpi(mainBranch, currentBranch) - printMsg(mfilename, ['The current feature (branch) is <' mainBranch '>.']); + printMsg(mfilename, ['The current branch is <' mainBranch '>.']); else fprintf(result_gitCheckout); - error([gitCmd.lead, 'An error occurred and the <' mainBranch '> feature (branch) cannot be checked out']); + error([gitCmd.lead, 'An error occurred and the <' mainBranch '> branch cannot be checked out']); end % reset the develop branch [status_gitReset, result_gitReset] = system(['git reset --hard upstream/' mainBranch]); if status_gitReset == 0 if gitConf.printLevel > 0 - fprintf([gitCmd.lead, ' [', mfilename, '] The current feature (branch) is <' mainBranch '>.', gitCmd.success, gitCmd.trail]); + fprintf([gitCmd.lead, ' [', mfilename, '] The current branch is <' mainBranch '>.', gitCmd.success, gitCmd.trail]); end else fprintf(result_gitReset); - error([gitCmd.lead, 'The <' mainBranch '> feature (branch) cannot be checked out']); + error([gitCmd.lead, 'The <' mainBranch '> branch cannot be checked out']); end % update all submodules @@ -86,10 +86,10 @@ function checkoutBranch(branchName, updateForkFlag) [status_gitPull, result_gitPull] = system(['git pull origin ' mainBranch]); if status_gitPull == 0 - printMsg(mfilename, ['The changes on the <' mainBranch '> feature (branch) of your fork have been pulled.']); + printMsg(mfilename, ['The changes on the <' mainBranch '> branch of your fork have been pulled.']); else fprintf(result_gitPull); - error([gitCmd.lead, 'The changes on the <' mainBranch '> feature (branch) could not be pulled.', gitCmd.fail]); + error([gitCmd.lead, 'The changes on the <' mainBranch '> branch could not be pulled.', gitCmd.fail]); end end @@ -107,7 +107,7 @@ function checkoutBranch(branchName, updateForkFlag) [status_gitCheckout, result_gitCheckout] = system(['git checkout ', checkoutFlag, ' ', branchName]); if status_gitCheckout == 0 - printMsg(mfilename, ['The <', branchName, '> feature (branch) has been checked out.']); + printMsg(mfilename, ['The <', branchName, '> branch has been checked out.']); % rebase if the branch already existed if ~strcmp(checkoutFlag, '-b') && isempty(strfind(branchName, 'develop')) && isempty(strfind(branchName, 'master')) @@ -121,15 +121,15 @@ function checkoutBranch(branchName, updateForkFlag) % if the message after rebase does not contain up to data and not cannot rebase if status_gitRebase == 0 && isempty(strfind(result_gitRebase, 'up to date')) && isempty(strfind(result_gitRebase, 'Cannot rebase')) - printMsg(mfilename, ['The <', branchName, '> feature (branch) has been rebased with <' mainBranch '>.']); + printMsg(mfilename, ['The <', branchName, '> branch has been rebased with <' mainBranch '>.']); % push by force the rebased branch [status_gitPush, result_gitPush] = system(['git push origin ', branchName, ' --force']); if status_gitPush == 0 - printMsg(mfilename, ['The <', branchName, '> feature (branch) has been pushed to your fork by force.']); + printMsg(mfilename, ['The <', branchName, '> branch has been pushed to your fork by force.']); else fprintf(result_gitPush); - error([gitCmd.lead, ' [', mfilename, '] The <', branchName ,'> feature (branch) could not be pushed to your fork.', gitCmd.fail]); + error([gitCmd.lead, ' [', mfilename, '] The <', branchName ,'> branch could not be pushed to your fork.', gitCmd.fail]); end else [status_gitRebaseAbort, ~] = system('git rebase --abort'); @@ -141,7 +141,7 @@ function checkoutBranch(branchName, updateForkFlag) % if the message after rebase contains : cannot rebase if ~isempty(strfind(result_gitRebase, 'Cannot rebase')) % ask the user first to reset - reply = input([gitCmd.lead, ' -> Do you want to reset your feature (branch) <', branchName, '>. Y/N [N]: '], 's'); + reply = input([gitCmd.lead, ' -> Do you want to reset your branch <', branchName, '>. Y/N [N]: '], 's'); if ~isempty(reply) || strcmpi(reply, 'y') || strcmpi(reply, 'yes') @@ -151,16 +151,16 @@ function checkoutBranch(branchName, updateForkFlag) % hard reset of an existing branch [status_gitReset, result_gitReset] = system(['git reset --hard origin/', branchName]); if status_gitReset == 0 - printMsg(mfilename, ['The <', branchName, '> feature (branch) has not been rebased with <' mainBranch '> and is up to date.']); + printMsg(mfilename, ['The <', branchName, '> branch has not been rebased with <' mainBranch '> and is up to date.']); else fprintf(result_gitReset); error([gitCmd.lead, ' [', mfilename, '] The <', branchName, '> could not be reset.', gitCmd.fail]); end else - printMsg(mfilename, ['The remote feature (branch) <', branchName, '> does not exist and could not be reset.'], [gitCmd.fail, gitCmd.trail]); + printMsg(mfilename, ['The remote branch <', branchName, '> does not exist and could not be reset.'], [gitCmd.fail, gitCmd.trail]); end else - printMsg(mfilename, ['The <', branchName, '> feature (branch) has not been reset.']); + printMsg(mfilename, ['The <', branchName, '> branch has not been reset.']); end end end @@ -170,22 +170,22 @@ function checkoutBranch(branchName, updateForkFlag) [status_gitPush, result_gitPush] = system(['git push origin ', branchName]); if status_gitPush == 0 - printMsg(mfilename, ['The <', branchName, '> feature (branch) has been pushed to your fork.']); + printMsg(mfilename, ['The <', branchName, '> branch has been pushed to your fork.']); else fprintf(result_gitPush); - error([gitCmd.lead, ' [', mfilename, '] The <', branchName, '> feature (branch) could not be pushed to your fork.', gitCmd.fail]); + error([gitCmd.lead, ' [', mfilename, '] The <', branchName, '> branch could not be pushed to your fork.', gitCmd.fail]); end end else if gitConf.printLevel > 0 fprintf(result_gitCheckout); - fprintf([gitCmd.lead, ' [', mfilename, '] The feature (branch) <', branchName, '> could not be checked out.', gitCmd.fail, gitCmd.trail]); + fprintf([gitCmd.lead, ' [', mfilename, '] The branch <', branchName, '> could not be checked out.', gitCmd.fail, gitCmd.trail]); end end else if gitConf.printLevel > 0 && ~strcmp(branchName, currentBranch) fprintf(result_gitStatus); - fprintf([gitCmd.lead, ' [', mfilename, '] Uncommited changes of the current feature (branch) <', currentBranch, '> have been migrated to the new feature <', branchName, '>.', gitCmd.success, gitCmd.trail]); + fprintf([gitCmd.lead, ' [', mfilename, '] Uncommited changes of the current branch <', currentBranch, '> have been migrated to the new branch <', branchName, '>.', gitCmd.success, gitCmd.trail]); end if ~strcmp(branchName, currentBranch) @@ -196,7 +196,7 @@ function checkoutBranch(branchName, updateForkFlag) currentBranch = getCurrentBranchName(); if status_gitCheckout == 0 && strcmpi(mainBranch, currentBranch) - printMsg(mfilename, ['The current feature (branch) is <' mainBranch '>.']); + printMsg(mfilename, ['The current branch is <' mainBranch '>.']); % update all submodules updateSubmodules(); @@ -205,17 +205,17 @@ function checkoutBranch(branchName, updateForkFlag) [status_gitPull, result_gitPull] = system(['git pull origin ' mainBranch]); if status_gitPull == 0 - printMsg(mfilename, ['The changes on the <' mainBranch '> feature (branch) of your fork have been pulled.']); + printMsg(mfilename, ['The changes on the <' mainBranch '> branch of your fork have been pulled.']); else fprintf(result_gitPull); - error([gitCmd.lead, 'The changes on the <' mainBranch '> feature (branch) could not be pulled.', gitCmd.fail]); + error([gitCmd.lead, 'The changes on the <' mainBranch '> branch could not be pulled.', gitCmd.fail]); end % checkout the branch but do not update the fork checkoutBranch(branchName, false); else fprintf(result_gitCheckout); - fprintf([gitCmd.lead 'The <' mainBranch '> feature (branch) cannot be checked out']); + fprintf([gitCmd.lead 'The <' mainBranch '> branch cannot be checked out']); end end end @@ -229,23 +229,23 @@ function checkoutBranch(branchName, updateForkFlag) % check if the branch exists remotely if branchExistsRemotely && branchExistsLocally - printMsg(mfilename, ['The <', branchName, '> feature (branch) exists locally and remotely on <', gitConf.forkURL, '>.']); + printMsg(mfilename, ['The <', branchName, '> branch exists locally and remotely on <', gitConf.forkURL, '>.']); else % the branch exists locally but not remotely! - reply = input([gitCmd.lead, ' -> Your <', branchName, '> feature (branch) exists locally, but not remotely. Do you want to have your local <', branchName, '> published? Y/N [Y]:'], 's'); + reply = input([gitCmd.lead, ' -> Your <', branchName, '> branch exists locally, but not remotely. Do you want to have your local <', branchName, '> published? Y/N [Y]:'], 's'); if isempty(reply) || strcmpi(reply, 'y') || strcmpi(reply, 'yes') % push the newly created branch to the fork [status_gitPush, result_gitPush] = system(['git push origin ', branchName]); if status_gitPush == 0 - printMsg(mfilename, ['The <', branchName, '> feature (branch) has been pushed to your fork.']); + printMsg(mfilename, ['The <', branchName, '> branch has been pushed to your fork.']); else fprintf(result_gitPush); - error([gitCmd.lead, ' [', mfilename, '] The <', branchName, '> feature (branch) could not be pushed to your fork.', gitCmd.fail]); + error([gitCmd.lead, ' [', mfilename, '] The <', branchName, '> branch could not be pushed to your fork.', gitCmd.fail]); end else - printMsg(mfilename, ['Your <', branchName, '> feature (branch) exists locally, but not remotely.'], gitCmd.trail); + printMsg(mfilename, ['Your <', branchName, '> branch exists locally, but not remotely.'], gitCmd.trail); end end diff --git a/src/deleteContribution.m b/src/deleteContribution.m index f60c390..1112a2e 100644 --- a/src/deleteContribution.m +++ b/src/deleteContribution.m @@ -1,5 +1,5 @@ function deleteContribution(branchName) -% Delete an existing feature (branch) named `branchName` +% Delete an existing branch named `branchName` % % USAGE: % @@ -28,7 +28,7 @@ function deleteContribution(branchName) while isempty(reply) || ~strcmpi(reply, 'yes') - reply = input([gitCmd.lead, originCall, 'Are you sure that you want to delete the feature (branch) <', branchName, '>? YES/NO [NO]: '], 's'); + reply = input([gitCmd.lead, originCall, 'Are you sure that you want to delete the branch <', branchName, '>? YES/NO [NO]: '], 's'); if strcmpi(reply, 'yes') % users MUST enter 'yes', not only 'y' @@ -61,16 +61,16 @@ function deleteContribution(branchName) [status_gitBranchDelete, result_gitBranchDelete] = system(['git branch -D ', branchName]); if status_gitBranchDelete == 0 - fprintf([gitCmd.lead, originCall, 'The local <', branchName, '> feature (branch) has been deleted.', gitCmd.success, gitCmd.trail]); + fprintf([gitCmd.lead, originCall, 'The local <', branchName, '> branch has been deleted.', gitCmd.success, gitCmd.trail]); else fprintf(result_gitBranchDelete); - error([gitCmd.lead, ' [', mfilename,'] The local <', branchName,'> feature (branch) could not be deleted. You might have unpublished/uncommitted changes.', gitCmd.fail]); + error([gitCmd.lead, ' [', mfilename,'] The local <', branchName,'> branch could not be deleted. You might have unpublished/uncommitted changes.', gitCmd.fail]); end else - fprintf([gitCmd.lead, originCall, 'The local <', branchName,'> feature (branch) does not exist.', gitCmd.fail, gitCmd.trail]); + fprintf([gitCmd.lead, originCall, 'The local <', branchName,'> branch does not exist.', gitCmd.fail, gitCmd.trail]); end else - error([gitCmd.lead, ' [', mfilename,'] The list of features (branches) could not be retrieved.', gitCmd.fail]); + error([gitCmd.lead, ' [', mfilename,'] The list of branches could not be retrieved.', gitCmd.fail]); end % delete the remote branch @@ -79,20 +79,20 @@ function deleteContribution(branchName) [status_gitPush, result_gitPush] = system(['git push origin --delete ', branchName]); if status_gitPush == 0 - fprintf([gitCmd.lead, originCall, 'The remote <', branchName, '> feature (branch) has been deleted.', gitCmd.success, gitCmd.trail]); + fprintf([gitCmd.lead, originCall, 'The remote <', branchName, '> branch has been deleted.', gitCmd.success, gitCmd.trail]); else fprintf(result_gitPush); - error([gitCmd.lead, ' [', mfilename,'] The remote <', branchName,'> feature (branch) could not be deleted.', gitCmd.fail]); + error([gitCmd.lead, ' [', mfilename,'] The remote <', branchName,'> branch could not be deleted.', gitCmd.fail]); end else - fprintf([gitCmd.lead, originCall, 'The remote <', branchName,'> feature (branch) does not exist.', gitCmd.fail, gitCmd.trail]); + fprintf([gitCmd.lead, originCall, 'The remote <', branchName,'> branch does not exist.', gitCmd.fail, gitCmd.trail]); end end end else - error([gitCmd.lead, ' [', mfilename,'] You cannot delete the or the feature (branch).', gitCmd.fail]); + error([gitCmd.lead, ' [', mfilename,'] You cannot delete the or the branch.', gitCmd.fail]); end - %list all available features - listFeatures(); + %list all available branches + listBranches(); end diff --git a/src/getCurrentBranchName.m b/src/getCurrentBranchName.m index 39023ec..e98ec57 100644 --- a/src/getCurrentBranchName.m +++ b/src/getCurrentBranchName.m @@ -20,9 +20,9 @@ if status == 0 currentBranch = currentBranch(1:end-1); - printMsg(mfilename, ['The name of the current feature (branch) is <', currentBranch, '>']); + printMsg(mfilename, ['The name of the current branch is <', currentBranch, '>']); else fprintf(currentBranch); - error([gitCmd.lead, ' [', mfilename, '] The name of the current feature (branch) could not be retrieved.', gitCmd.fail]); + error([gitCmd.lead, ' [', mfilename, '] The name of the current branch could not be retrieved.', gitCmd.fail]); end end diff --git a/src/initContribution.m b/src/initContribution.m index 3c009a7..6cf8aa7 100644 --- a/src/initContribution.m +++ b/src/initContribution.m @@ -1,5 +1,5 @@ function initContribution(branchName) -% Initializes a new feature (branch) named `branchName` +% Initializes a new branch named `branchName` % % USAGE: % @@ -26,11 +26,11 @@ function initContribution(branchName) checkoutFlag = false; while ~checkoutFlag - % request a name of the new feature + % request a name of the new branch if nargin < 1 || nargin == 1 && (strcmpi(branchName, '') || ~isempty(strfind(branchName, 'develop')) || ~isempty(strfind(branchName, 'master'))) branchName = ''; while isempty(branchName) && ~checkoutFlag - branchName = input([gitCmd.lead, originCall, ' -> Please enter a name of the feature that you want to work on (example: add-constraints): '], 's'); + branchName = input([gitCmd.lead, originCall, ' -> Please enter a name of the branch that you want to work on (example: add-constraints): '], 's'); if ~isempty(strfind(branchName, 'develop')) || ~isempty(strfind(branchName, 'master')) branchName = ''; fprintf([gitCmd.lead, ' -> Please use a different name that does not contain or .', gitCmd.fail, gitCmd.trail]); @@ -47,12 +47,12 @@ function initContribution(branchName) % check if the branch already exists, and if, ask if the user wants to continue if checkBranchExistence(branchName) && checkoutFlag - % list the available features if the fork is already configured + % list the available branches if the fork is already configured if exist('gitConf.fullForkDir', 'var') - listFeatures(); + listBranches(); end - reply = input([gitCmd.lead, ' -> You already worked on a feature (branch) named <', branchName, '>. Do you want to continue working on <', branchName, '>? Y/N [Y]:'], 's'); + reply = input([gitCmd.lead, ' -> You already worked on a branch named <', branchName, '>. Do you want to continue working on <', branchName, '>? Y/N [Y]:'], 's'); if isempty(reply) || strcmpi(reply, 'y') || strcmpi(reply, 'yes') checkoutFlag = true; @@ -64,19 +64,19 @@ function initContribution(branchName) end end - % checkout the branch of the feature + % checkout the branch if checkoutFlag checkoutBranch(branchName); % provide a success message fprintf([gitCmd.lead, gitCmd.trail]); - fprintf([gitCmd.lead, ' -> You may now start working on your new feature (branch) <', branchName, '>.', gitCmd.trail]); + fprintf([gitCmd.lead, ' -> You may now start working on your new branch <', branchName, '>.', gitCmd.trail]); end % provide instructions fprintf([gitCmd.lead, gitCmd.trail]); fprintf([gitCmd.lead, ' For future reference:', gitCmd.trail]); - fprintf([gitCmd.lead, ' -> Run "contribute" and select "2" to choose the feature (branch) to work on.', gitCmd.trail]); - fprintf([gitCmd.lead, ' -> Run "contribute" and select "3" to publish your feature (branch) named <', branchName, '>.', gitCmd.trail]); - fprintf([gitCmd.lead, ' -> Run "contribute" and select "4" to delete your feature (branch) named <', branchName, '>.', gitCmd.trail]); + fprintf([gitCmd.lead, ' -> Run "contribute" and select "2" to choose the branch to work on.', gitCmd.trail]); + fprintf([gitCmd.lead, ' -> Run "contribute" and select "3" to publish your branch named <', branchName, '>.', gitCmd.trail]); + fprintf([gitCmd.lead, ' -> Run "contribute" and select "4" to delete your branch named <', branchName, '>.', gitCmd.trail]); end diff --git a/src/listFeatures.m b/src/listBranches.m similarity index 83% rename from src/listFeatures.m rename to src/listBranches.m index dca884f..85ae1ff 100644 --- a/src/listFeatures.m +++ b/src/listBranches.m @@ -1,9 +1,9 @@ -function [exitFlag, currentBranch, arrResult, exampleBranch] = listFeatures() -% Lists all available branches/features +function [exitFlag, currentBranch, arrResult, exampleBranch] = listBranches() +% Lists all available branches % % USAGE: % -% [exitFlag, currentBranch, arrResult, exampleBranch] = listFeatures() +% [exitFlag, currentBranch, arrResult, exampleBranch] = listBranches() % % OUTPUT: % exitFlag: Boolean (true if proper exit of function) @@ -49,9 +49,9 @@ arrResult = arrResult(~cellfun(@isempty, arrResult)); if length(arrResult) > nbBranches - fprintf('\n Available features are:\n'); + fprintf('\n Available branches are:\n'); - % list the number of available features + % list the number of available branches for i = 1:length(arrResult) tmpName = arrResult(i); tmpName = tmpName{1}; @@ -68,9 +68,9 @@ reply = ''; while isempty(reply) - reply = input(' -> You do not have any features (branches). Do you want to start a new feature (branch)? Y/N [Y]: ', 's'); + reply = input(' -> You do not have any branches. Do you want to start a new branch? Y/N [Y]: ', 's'); - % decide whether to start a new feature (branch) or not + % decide whether to start a new branch or not if strcmpi(reply, 'y') || strcmpi(reply, 'yes') initContribution; exitFlag = true; diff --git a/src/openPR.m b/src/openPR.m index cb6111a..df87a44 100644 --- a/src/openPR.m +++ b/src/openPR.m @@ -38,8 +38,9 @@ function openPR(branchName) 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']); + 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); - error([gitCmd.lead, ' [', mfilename,'] The feature (branch) <', branchName, '> does not exist or has no commits.', gitCmd.fail]) + error([gitCmd.lead, ' [', mfilename,'] The branch <', branchName, '> does not exist or has no commits.', gitCmd.fail]) end end diff --git a/src/submitContribution.m b/src/submitContribution.m index 9267fd8..6b12994 100644 --- a/src/submitContribution.m +++ b/src/submitContribution.m @@ -1,5 +1,5 @@ function submitContribution(branchName) -% Submit an existing feature (branch) named `branchName` +% Submit an existing branch named `branchName` % % USAGE: % @@ -43,7 +43,7 @@ function submitContribution(branchName) addFileOrder = false; fprintf([gitCmd.lead, originCall, 'There is nothing to contribute. Please make changes to ', strrep(pwd, '\', '\\'), gitCmd.trail]); - reply = input([gitCmd.lead, originCall, ' -> Do you want to open a pull request (PR) and submit your feature (branch) <', branchName, '>? Y/N [N]: '], 's'); + reply = input([gitCmd.lead, originCall, ' -> Do you want to open a pull request (PR) and submit your branch <', branchName, '>? Y/N [N]: '], 's'); if ~isempty(reply) && (strcmpi(reply, 'y') || strcmpi(reply, 'yes')) openPR(branchName); @@ -223,11 +223,11 @@ function submitContribution(branchName) % push to the branch in the fork if pushStatus - fprintf([gitCmd.lead, originCall, 'Pushing ', num2str(countAddFiles), ' change(s) to your feature (branch) <', branchName, '>', gitCmd.trail]) + fprintf([gitCmd.lead, originCall, 'Pushing ', num2str(countAddFiles), ' change(s) to your branch <', branchName, '>', gitCmd.trail]) [status_gitPush, result_gitPush] = system(['git push origin ', branchName, ' --force']); if status_gitPush == 0 - reply = input([gitCmd.lead, originCall, ' -> Do you want to open a pull request (PR) and submit your feature (branch) <', branchName, '>? Y/N [N]: '], 's'); + reply = input([gitCmd.lead, originCall, ' -> Do you want to open a pull request (PR) and submit your branch <', branchName, '>? Y/N [N]: '], 's'); if ~isempty(reply) && (strcmpi(reply, 'y') || strcmpi(reply, 'yes')) openPR(branchName); diff --git a/src/updateFork.m b/src/updateFork.m index f66b36d..81a58c3 100644 --- a/src/updateFork.m +++ b/src/updateFork.m @@ -65,7 +65,7 @@ function updateFork(force) error([gitCmd.lead, ' [', mfilename, '] Impossible to fetch changes from fork.', gitCmd.fail]); end else - printMsg(mfilename, ['The develop feature (branch) does not exist on the fork.'], [gitCmd.fail, gitCmd.trail]); + printMsg(mfilename, ['The develop branch does not exist on the fork.'], [gitCmd.fail, gitCmd.trail]); end % fetch the changes from upstream @@ -84,20 +84,20 @@ function updateFork(force) [status_gitCheckout, result_gitCheckout] = system(['git checkout ', branches{k}]); if status_gitCheckout == 0 - printMsg(mfilename, ['The feature (branch) <', branches{k}, '> was checked out.']); + printMsg(mfilename, ['The branch <', branches{k}, '> was checked out.']); else fprintf(result_gitCheckout); - printMsg(mfilename, ['The feature (branch) <', branches{k}, '> could not be checked out.']); + printMsg(mfilename, ['The branch <', branches{k}, '> could not be checked out.']); end else [status_gitCheckoutCreate, result_gitCheckoutCreate] = system(['git checkout -b ', branches{k}]); if status_gitCheckoutCreate == 0 - printMsg(mfilename, ['The feature (branch) <', branches{k}, '> was checked out.']); + printMsg(mfilename, ['The branch <', branches{k}, '> was checked out.']); else fprintf(result_gitCheckoutCreate); - printMsg(mfilename, ['The feature (branch) <', branches{k}, '> could not be checked out.']); + printMsg(mfilename, ['The branch <', branches{k}, '> could not be checked out.']); end end @@ -114,10 +114,10 @@ function updateFork(force) [status_gitPull, result_gitPull] = system(['git pull origin ', branches{k}]); if status_gitPull == 0 - printMsg(mfilename, ['The <', branches{k}, '> feature (branch) of the fork could not be pulled.']); + printMsg(mfilename, ['The <', branches{k}, '> branch of the fork could not be pulled.']); else fprintf(result_gitPull); - error([gitCmd.lead, ' [', mfilename,'] Impossible to pull changes from the <', branches{k}, '> feature (branch) of the fork.', gitCmd.fail]); + error([gitCmd.lead, ' [', mfilename,'] Impossible to pull changes from the <', branches{k}, '> branch of the fork.', gitCmd.fail]); end if ~force @@ -134,10 +134,10 @@ function updateFork(force) if force [status_gitReset, result_gitReset] = system(['git reset --hard upstream/', branches{k}]); if status_gitReset == 0 - printMsg(mfilename, ['The <', branches{k}, '> feature (branch) of the fork has been reset.']); + printMsg(mfilename, ['The <', branches{k}, '> branch of the fork has been reset.']); else fprintf(result_gitReset); - error([gitCmd.lead, ' [', mfilename,'] Impossible to reset the <', branches{k}, '> feature (branch) of the fork.', gitCmd.fail]); + error([gitCmd.lead, ' [', mfilename,'] Impossible to reset the <', branches{k}, '> branch of the fork.', gitCmd.fail]); end % set the flag for a force push @@ -156,10 +156,10 @@ function updateFork(force) [status_gitPush, result_gitPush] = system(['git push origin ', branches{k}, ' ', forceFlag]); if status_gitPush == 0 - printMsg(mfilename, ['The <', branches{k}, '> feature (branch) has been updated on the fork', forceText, '.']); + printMsg(mfilename, ['The <', branches{k}, '> branch has been updated on the fork', forceText, '.']); else fprintf(result_gitPush); - error([gitCmd.lead, ' [', mfilename,'] Impossible to update the <', branches{k}, '> feature (branch) on your fork (', gitConf.forkURL, ').', gitCmd.fail]); + error([gitCmd.lead, ' [', mfilename,'] Impossible to update the <', branches{k}, '> branch on your fork (', gitConf.forkURL, ').', gitCmd.fail]); end end end @@ -169,7 +169,7 @@ function updateFork(force) updateSubmodules(); else fprintf(resultList); - error([gitCmd.lead, ' [', mfilename,'] Impossible to retrieve the features (branches) of your local fork.', gitCmd.fail]); + error([gitCmd.lead, ' [', mfilename,'] Impossible to retrieve the branches of your local fork.', gitCmd.fail]); end else fprintf(result_gitStatus); diff --git a/test/testCheckSystem.m b/test/testCheckSystem.m index b31931e..29517b5 100644 --- a/test/testCheckSystem.m +++ b/test/testCheckSystem.m @@ -65,8 +65,8 @@ delete('test-CI.txt'); -% list available features -listFeatures(); +% list available branches +listBranches(); % check the status of the repository checkStatus();