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
+44-23
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,20 @@
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
5
5
%
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
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,31 +71,37 @@ 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 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
64
84
85
+
% evaluate the option
65
86
if length(choice) ==0||choice>5||choice<0
66
87
error('Please enter a number between 1 and 5.')
67
88
else
68
89
if ~isempty(choice) && length(choice) >0
69
-
% ask for a name of the feature/branch
90
+
% ask for a name of the branch
70
91
ifchoice==1
71
92
72
-
% list the available features if the fork is already configured
93
+
% list the available branches if the fork is already configured
73
94
if exist('gitConf.fullForkDir', 'var')
74
-
%list all available features
75
-
listFeatures();
95
+
%list all available branches
96
+
listBranches();
76
97
end
77
98
78
99
% define a name of an example branch
79
100
exampleBranch =gitConf.exampleBranch;
80
101
81
102
reply ='';
82
103
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');
84
105
if ~isempty(strfind(reply, 'develop')) || ~isempty(strfind(reply, 'master'))
85
106
reply ='';
86
107
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)
0 commit comments