Skip to content

Commit 454b654

Browse files
Comments and simplifying conditional statements
1 parent eab0ad2 commit 454b654

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

contribute.m

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,13 @@ function contribute(repoName, printLevel, autoOption)
3030
addpath(genpath(fileparts(which(mfilename))));
3131

3232
% check the automatic option argument
33+
autoOptionFlag = false;
3334
if exist('autoOption', 'var')
34-
if ~isempty(autoOption)
35-
if autoOption > 0 && autoOption < 6
36-
autoOptionFlag = true;
37-
else
38-
error('Please enter an automatic menu option between 1 and 5.')
39-
end
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.')
4039
end
41-
else
42-
autoOptionFlag = false;
4340
end
4441

4542
% treatment of input arguments
@@ -49,11 +46,9 @@ function contribute(repoName, printLevel, autoOption)
4946
end
5047

5148
% soft reset if the repository name is different
52-
if ~isempty(gitConf)
53-
if isfield(gitConf, 'remoteUserName') && isfield(gitConf, 'remoteRepoName')
54-
if exist('repoName', 'var') && ~strcmpi(repoName, [gitConf.remoteUserName '/' gitConf.remoteRepoName])
55-
resetDevTools();
56-
end
49+
if ~isempty(gitConf) && exist('repoName', 'var') && isfield(gitConf, 'remoteUserName') && isfield(gitConf, 'remoteRepoName')
50+
if ~strcmpi(repoName, [gitConf.remoteUserName '/' gitConf.remoteRepoName])
51+
resetDevTools();
5752
end
5853
end
5954

@@ -64,8 +59,10 @@ function contribute(repoName, printLevel, autoOption)
6459
checkSystem(mfilename, repoName);
6560
end
6661

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

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

7168
% change to the directory of the devTools
@@ -74,15 +71,18 @@ function contribute(repoName, printLevel, autoOption)
7471
% update the devTools
7572
updateDevTools();
7673

74+
% print the launcher
7775
fprintf(gitConf.launcher);
7876

77+
% show the menu to select an option
7978
if autoOptionFlag
8079
choice = autoOption;
8180
else
8281
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');
8382
choice = str2num(choice);
8483
end
8584

85+
% evaluate the option
8686
if length(choice) == 0 || choice > 5 || choice < 0
8787
error('Please enter a number between 1 and 5.')
8888
else

0 commit comments

Comments
 (0)