Skip to content

Commit 19990fe

Browse files
Merge pull request #19 from opencobra/develop
Regular merge of develop
2 parents b767079 + cea7991 commit 19990fe

21 files changed

+175
-670
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "external/rdir"]
2+
path = external/rdir
3+
url = https://github.com/uni-lu/rdir.git

README.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ You will then be presented by a menu:
9797

9898
::
9999

100-
[1] Start a new feature (branch).
101-
[2] Select an existing feature (branch) to work on.
102-
[3] Publish a feature (branch).
103-
[4] Delete a feature (branch).
100+
[1] Start a new branch.
101+
[2] Select an existing branch to work on.
102+
[3] Publish a branch.
103+
[4] Delete a branch.
104104
[5] Update the fork.
105105

106106
-> Please select what you want to do (enter the number):

contribute.m

+44-23
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
function contribute(repoName, printLevel)
1+
function contribute(repoName, printLevel, autoOption)
22
% devTools
33
%
44
% PURPOSE: displays a menu and calls the respective subfunctions
55
%
6-
% 1. Start a new feature (branch):
7-
% 2. Select an existing feature (branch) to work on.
8-
% 3. Publish a feature (branch).
9-
% 4. Delete a feature (branch).
6+
% 1. Start a new branch:
7+
% 2. Select an existing branch to work on.
8+
% 3. Publish a branch.
9+
% 4. Delete a branch.
10+
% 5. Update the fork
1011
%
1112
% INPUT:
1213
%
14+
% repoName: Name of the repository (default: opencobra/cobratoolbox)
1315
% printLevel: 0: minimal printout (default)
1416
% 1: detailed printout (debug mode)
17+
% autoOption: menu option
1518

1619
global gitConf
1720
global gitCmd
@@ -26,14 +29,24 @@ function contribute(repoName, printLevel)
2629
% adding the src folder of the devTools
2730
addpath(genpath(fileparts(which(mfilename))));
2831

32+
% check the automatic option argument
33+
autoOptionFlag = false;
34+
if exist('autoOption', 'var')
35+
if ~isempty(autoOption) && autoOption > 0 && autoOption < 6
36+
autoOptionFlag = true;
37+
else
38+
error('Please enter an automatic menu option between 1 and 5.')
39+
end
40+
end
41+
2942
% treatment of input arguments
30-
if ~exist('repoName', 'var')
43+
if ~exist('repoName', 'var') || isempty(repoName)
3144
DEFAULTREPONAME = 'opencobra/cobratoolbox'; % set the default repository
3245
repoName = DEFAULTREPONAME;
3346
end
3447

3548
% soft reset if the repository name is different
36-
if ~isempty(gitConf)
49+
if ~isempty(gitConf) && exist('repoName', 'var') && isfield(gitConf, 'remoteUserName') && isfield(gitConf, 'remoteRepoName')
3750
if ~strcmpi(repoName, [gitConf.remoteUserName '/' gitConf.remoteRepoName])
3851
resetDevTools();
3952
end
@@ -46,8 +59,10 @@ function contribute(repoName, printLevel)
4659
checkSystem(mfilename, repoName);
4760
end
4861

62+
% perform a soft reset if interrupted
4963
finishup = onCleanup(@() resetDevTools());
5064

65+
% determine the directory of the devTools
5166
devToolsDir = fileparts(which(mfilename));
5267

5368
% change to the directory of the devTools
@@ -56,31 +71,37 @@ function contribute(repoName, printLevel)
5671
% update the devTools
5772
updateDevTools();
5873

74+
% print the launcher
5975
fprintf(gitConf.launcher);
6076

61-
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');
62-
63-
choice = str2num(choice);
77+
% show the menu to select an option
78+
if autoOptionFlag
79+
choice = autoOption;
80+
else
81+
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');
82+
choice = str2num(choice);
83+
end
6484

85+
% evaluate the option
6586
if length(choice) == 0 || choice > 5 || choice < 0
6687
error('Please enter a number between 1 and 5.')
6788
else
6889
if ~isempty(choice) && length(choice) > 0
69-
% ask for a name of the feature/branch
90+
% ask for a name of the branch
7091
if choice == 1
7192

72-
% list the available features if the fork is already configured
93+
% list the available branches if the fork is already configured
7394
if exist('gitConf.fullForkDir', 'var')
74-
%list all available features
75-
listFeatures();
95+
%list all available branches
96+
listBranches();
7697
end
7798

7899
% define a name of an example branch
79100
exampleBranch = gitConf.exampleBranch;
80101

81102
reply = '';
82103
while isempty(reply)
83-
reply = input([' -> Please enter a name of the new feature (branch) that you want to work on (example: ', exampleBranch, '): '], 's');
104+
reply = input([' -> Please enter a name of the new branch that you want to work on (example: ', exampleBranch, '): '], 's');
84105
if ~isempty(strfind(reply, 'develop')) || ~isempty(strfind(reply, 'master'))
85106
reply = '';
86107
fprintf([gitCmd.lead, 'Please use a different name that does not contain <develop> or <master>.', gitCmd.fail, gitCmd.trail]);
@@ -94,8 +115,8 @@ function contribute(repoName, printLevel)
94115
% change to the fork diretory
95116
cd(gitConf.fullForkDir);
96117

97-
%list all available features
98-
[exitFlag, currentBranch, ~, exampleBranch] = listFeatures();
118+
%list all available branches
119+
[exitFlag, currentBranch, ~, exampleBranch] = listBranches();
99120

100121
if ~strcmpi('develop', currentBranch) && ~strcmpi('master', currentBranch)
101122
exampleBranch = currentBranch;
@@ -105,22 +126,22 @@ function contribute(repoName, printLevel)
105126
reply = '';
106127
if choice == 2
107128
while isempty(reply) && ~exitFlag
108-
reply = input([' -> Please enter the name of the existing feature (branch) that you want to work on (example: ', exampleBranch, '): '], 's');
129+
reply = input([' -> Please enter the name of the existing branch that you want to work on (example: ', exampleBranch, '): '], 's');
109130
end
110131
elseif choice == 3
111132
while isempty(reply)
112-
reply = input([' -> Please enter the name of the feature (branch) that you want to publish (example: ', exampleBranch, '): '], 's');
133+
reply = input([' -> Please enter the name of the branch that you want to publish (example: ', exampleBranch, '): '], 's');
113134
end
114135
elseif choice == 4
115136

116-
% list the available features if the fork is already configured
137+
% list the available branches if the fork is already configured
117138
if exist('gitConf.fullForkDir', 'var')
118-
%list all available features
119-
listFeatures();
139+
%list all available branches
140+
listBranches();
120141
end
121142

122143
while isempty(reply)
123-
reply = input([' -> Please enter the name of the feature (branch) that you want to delete (example: ', exampleBranch, '): '], 's');
144+
reply = input([' -> Please enter the name of the branch that you want to delete (example: ', exampleBranch, '): '], 's');
124145
end
125146
end
126147
end

docs/source/bestpractices.rst

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.. _bestpractices:
2+
3+
Best practices
4+
==============
5+
6+
Naming a contribution
7+
---------------------
8+
9+
Initiate a contribution per theme/topic/feature/bug fix that you work
10+
on. Don’t mix features and think of an explicit name, i.e.
11+
``bug-fix-function1`` or ``add-tests-function2``. Avoid generic names,
12+
such as ``my-great-feature`` or ``fix`` or ``contribution-myName``.
13+
14+
Submitting a Pull Request (PR)
15+
------------------------------
16+
17+
Once you submit your contribution (menu option [3]), you will be
18+
presented with a link that leads you directly to the pull request (PR).
19+
Once the PR is submitted, wait until it is reviewed and accepted.
20+
Once merged, please start a new branch by running ``contribute`` and
21+
selecting [1] after your pull request has been reviewed and merged.

docs/source/contents.rst

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ MATLAB.devTools
88
installation
99
getstarted
1010
contribute
11+
bestpractices
1112
modules/index
1213
faq
1314
troubleshooting

docs/source/contr_cobratoolbox.rst

+4-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Introduction
1212

1313
A comprehensive code base such as the COBRA Toolbox evolves constantly. The
1414
open-source community is very active, and collaborators submit their
15-
contributions frequently. The more a new feature or bug fix is interlinked with
15+
contributions frequently. The more a change to code or bug fix is interlinked with
1616
existing functions, the higher the risk of a new addition breaking instantly
1717
code that is heavily used on a daily basis. In order to decrease this risk, a
1818
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.
2222
Any incremental changes to the code are called commits. The main advantage of
2323
git over other version control systems is the availability of branches. In
2424
simple terms, a branch contains a sequence of incremental changes to the code.
25-
A branch is also commonly referred to as a feature. Consequently, a
26-
contribution generally consists of several commits on a branch.
25+
Consequently, a contribution generally consists of several commits on a branch.
2726

2827
Contributing to the COBRA Toolbox is straightforward. As a contributor to the
2928
COBRA Toolbox is likely more familiar with MATLAB than with the internal
@@ -170,12 +169,12 @@ Deleting a contribution
170169
-----------------------
171170

172171
If a contribution has been merged into the develop branch of the opencobra
173-
repository (accepted pull request), the contribution (feature or branch) can be
172+
repository (accepted pull request), the contribution (branch) can be
174173
safely deleted both locally and remotely on the fork by running contribute and
175174
selecting procedure ``[4]``.
176175

177176
Note that deleting a contribution deletes all the changes that have been made
178-
on that feature (branch). It is not possible to selectively delete a commit
177+
on that branch. It is not possible to selectively delete a commit
179178
using the MATLAB.devTools. Instead, create a new branch by following procedure
180179
``[1]``, and follow the instructions to cherry-pick (see
181180
:ref:`troubleshooting`).

docs/source/faq.rst

+1-15
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ Frequently Asked Questions (FAQ)
66
General questions
77
-----------------
88

9-
How should I name my contribution?
10-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11-
12-
Initiate a contribution per theme/topic/feature/bug fix that you work
13-
on. Don’t mix features and think of an explicit name, i.e.
14-
``bug-fix-function1`` or ``add-tests-function2``. Avoid generic names,
15-
such as ``my-great-feature`` or ``fix`` or ``contribution-myName``.
16-
179
How can I check the history of a file?
1810
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1911

@@ -23,12 +15,6 @@ You can check the history of a file by typing in MATLAB:
2315
2416
>> history('fileName.m')
2517
26-
How do I submit a Pull Request (PR)?
27-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28-
29-
Once you submit your contribution (menu option [3]), you will be
30-
presented with a link that leads you directly to the pull request (PR).
31-
3218
Print more detailed debugging information (verbose)
3319
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3420

@@ -62,7 +48,7 @@ You may encounter the following error:
6248

6349
This error can have multiple reasons, but most likely, the SSH key is
6450
not configured properly. Please follow the `configuration
65-
instructions <https://github.com/opencobra/MATLAB.devTools/blob/master/PREREQUISITES.md>`__
51+
instructions <https://opencobra.github.io/MATLAB.devTools/stable/installation.html#pre-requisites>`__
6652
carefully.
6753

6854
Another source of this error may be that you have set a passphrase when

docs/source/troubleshooting/cobratoolbox.rst

+16-16
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ COBRA Toolbox are consequently commits that are made on branches.
2323

2424
The development scheme adopted in the repository of the COBRA Toolbox has two
2525
branches: a `master` and a `develop` branch. The stable branch is the `master`
26-
branch, while it is the `develop` branch that includes all new features and to
26+
branch, while it is the `develop` branch that includes all new changes to code and to
2727
which new contributions are merged. Contributions are submitted for review and
2828
testing through pull requests, the `git` standard. The `develop` branch is
29-
regularly merged into the `master` branch once testing is concluded.
29+
regularly merged into the `master` branch once testing is concluded.
3030

3131
The development scheme has been adopted for obvious reasons: the COBRA Toolbox
3232
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
5555
to be run from within the folder of the fork called `fork-cobratoolbox`.
5656

5757
.. code:: console
58-
58+
5959
$ cd fork-cobratoolbox
6060
6161
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
125125
from the `develop` branch. Create the new branch:
126126

127127
.. code:: console
128-
128+
129129
$ git checkout -b <myBranch> develop
130130
131131
Now, you can make changes in the folder `fork-cobratoolbox`. Once you are done
@@ -145,29 +145,29 @@ adding the file:
145145
146146
|warning| Contrary to what is sometimes provided as a shortcut, it is not
147147
advised to add all files all at once using as this command will add all files,
148-
even hidden files and binaries.
148+
even hidden files and binaries.
149149

150150
.. code:: console
151151
152-
$ git add . # bad practice
152+
$ git add . # bad practice
153153
154-
Then, commit the changes by setting a commit message <yourMessage>:
154+
Then, commit the changes by setting a commit message <yourMessage>:
155155

156156
.. code:: console
157157
158158
$ git commit -m "<myMessage>"
159159
160-
Finally, push your commit to Github:
160+
Finally, push your commit to Github:
161161

162162
.. code:: console
163163
164-
$ git push origin <myBranch>
164+
$ git push origin <myBranch>
165165
166166
You should then see your commit online, and if ready, you can open a
167167
pull request. You can select your branch in the dropdown menu and list all
168168
commits by clicking on `commits`.
169169

170-
Continue working on your branch after a while (rebase)
170+
Continue working on your branch after a while (rebase)
171171
------------------------------------------------------
172172

173173
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
177177
any uncommitted or local changes (git status).
178178

179179
.. code:: console
180-
180+
181181
$ git checkout develop
182182
$ git fetch upstream
183183
$ git merge upstream/develop
@@ -191,26 +191,26 @@ use a merge tool such as `kdiff3`. In order to install a merge tool or abort
191191
the rebase process, type:
192192

193193
.. code:: console
194-
194+
195195
$ git rebase --abort
196196
197197
In order to have the changes on `<myBranch>` reflected in the online
198198
repository, push the changes with force. Pushing with force is required as the
199199
history of the branch has been rewritten during rebase.
200200

201201
.. code:: console
202-
202+
203203
$ git push <myBranch> --force
204204
205-
Selectively use a commit on your branch (cherry-pick)
205+
Selectively use a commit on your branch (cherry-pick)
206206
-----------------------------------------------------
207207

208208
Imagine having two branches called `<myBranch-1>` and `<myBranch-2>`. On branch
209209
`<myBranch-1>` is a commit with a SHA1 that you need on `<myBranch-2>`. You can
210210
cherry-pick the commit from `<myBranch-1>` to `<myBranch-2>` by typing:
211211

212212
.. code:: console
213-
213+
214214
$ git checkout myBranch-2
215215
$ git cherry-pick SHA1
216216
@@ -219,6 +219,6 @@ message and author information. In order to have the commit listed online,
219219
conclude the cherry-pick by pushing the commit to the remote repository:
220220

221221
.. code:: console
222-
222+
223223
$ git push myBranch-2
224224

external/rdir

Submodule rdir added at 0bfa4a3

0 commit comments

Comments
 (0)