Skip to content

Commit

Permalink
Added check for updates to Datamaster constructor
Browse files Browse the repository at this point in the history
Only runs once per session
  • Loading branch information
awadell1 committed Jan 30, 2017
1 parent 60e2f65 commit fabd410
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions @Datamaster/Datamaster.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,33 @@

% Get a list of Details and Channels that have been logged
dm.updateDetails; dm.updateChannels;

%% Check for Updates - But Only once per session
persistent flagChecked
if isempty(flagChecked)
%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');

%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']);
end

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

%% Small Public Methods -> Move externally if it grows
Expand Down

0 comments on commit fabd410

Please sign in to comment.