You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: contribute.m
+27-6Lines changed: 27 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
function contribute(repoName, printLevel)
1
+
function contribute(repoName, printLevel, autoOption)
2
2
% devTools
3
3
%
4
4
% PURPOSE: displays a menu and calls the respective subfunctions
@@ -7,11 +7,14 @@ function contribute(repoName, printLevel)
7
7
% 2. Select an existing feature (branch) to work on.
8
8
% 3. Publish a feature (branch).
9
9
% 4. Delete a feature (branch).
10
+
% 5. Update the fork
10
11
%
11
12
% INPUT:
12
13
%
14
+
% repoName: Name of the repository (default: opencobra/cobratoolbox)
13
15
% printLevel: 0: minimal printout (default)
14
16
% 1: detailed printout (debug mode)
17
+
% autoOption: menu option
15
18
16
19
globalgitConf
17
20
globalgitCmd
@@ -26,14 +29,24 @@ function contribute(repoName, printLevel)
26
29
% adding the src folder of the devTools
27
30
addpath(genpath(fileparts(which(mfilename))));
28
31
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
+
29
42
% treatment of input arguments
30
-
if ~exist('repoName', 'var')
43
+
if ~exist('repoName', 'var')|| isempty(repoName)
31
44
DEFAULTREPONAME ='opencobra/cobratoolbox'; % set the default repository
32
45
repoName =DEFAULTREPONAME;
33
46
end
34
47
35
48
% 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')
37
50
if ~strcmpi(repoName, [gitConf.remoteUserName '/'gitConf.remoteRepoName])
38
51
resetDevTools();
39
52
end
@@ -46,8 +59,10 @@ function contribute(repoName, printLevel)
46
59
checkSystem(mfilename, repoName);
47
60
end
48
61
62
+
% perform a soft reset if interrupted
49
63
finishup = onCleanup(@() resetDevTools());
50
64
65
+
% determine the directory of the devTools
51
66
devToolsDir = fileparts(which(mfilename));
52
67
53
68
% change to the directory of the devTools
@@ -56,12 +71,18 @@ function contribute(repoName, printLevel)
56
71
% update the devTools
57
72
updateDevTools();
58
73
74
+
% print the launcher
59
75
fprintf(gitConf.launcher);
60
76
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
+
ifautoOptionFlag
79
+
choice =autoOption;
80
+
else
81
+
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');
0 commit comments