Skip to content

Commit

Permalink
Added try catch loop to update check code
Browse files Browse the repository at this point in the history
Intended to prevent unforseen failures crashing datamaster
If unable to update -> Stops trying to prevent user annoyance
  • Loading branch information
awadell1 committed Jan 30, 2017
1 parent fabd410 commit a8d1ce0
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions @Datamaster/Datamaster.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,35 @@
%% Check for Updates - But Only once per session
persistent flagChecked
if isempty(flagChecked)
%Move to the Datamaster folder
savedCd = cd; cd(Datamaster.getPath);
try
%Move to the Datamaster folder
savedCd = cd; cd(Datamaster.getPath);

%Fetch updates from remote
[success, ~] = system('git fetch');
assert(success==0, 'Error fetching updates from remote');
%Fetch updates from remote
[success, ~] = system('git fetch');
assert(success==0, 'Error fetching updates from remote');

%Check Current Status
[success, str] = system('git status');
assert(success==0, 'Error reading git repo status');
%Check Current Status
[success, str] = system('git status');
assert(success==0, 'Error reading git repo status');

%Get status
status = regexpi(str, 'Your branch is behind ''(.+)'' by (\d+)', 'tokens');

%Report to user
if ~isempty(status)
warning(['Updates are avaliable. ',...
'Run <a href="matlab:DatamasterSetup">Datamaster Setup</a> to Update']);
%Get status
status = regexpi(str, 'Your branch is behind ''(.+)'' by (\d+)', 'tokens');

%Report to user
if ~isempty(status)
warning(['Updates are avaliable. ',...
'Run <a href="matlab:DatamasterSetup">Datamaster Setup</a> to Update']);
end

%Return to original directory
cd(savedCd); flagChecked = true;
catch
%Warn user that we were unable to check for updates but
%don't recheck this session
warning('Unable to check for updates');
flagChecked = true;
end

%Return to original directory
cd(savedCd); flagChecked = true;
end
end

Expand Down

0 comments on commit a8d1ce0

Please sign in to comment.