From fabd4109a63f36722f66bdff27c61611d2b00084 Mon Sep 17 00:00:00 2001 From: Alexius Wadell Date: Sun, 29 Jan 2017 20:39:07 -0500 Subject: [PATCH] Added check for updates to Datamaster constructor Only runs once per session --- @Datamaster/Datamaster.m | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/@Datamaster/Datamaster.m b/@Datamaster/Datamaster.m index 66f7fca..8049371 100644 --- a/@Datamaster/Datamaster.m +++ b/@Datamaster/Datamaster.m @@ -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 Datamaster Setup to Update']); + end + + %Return to original directory + cd(savedCd); flagChecked = true; + end end %% Small Public Methods -> Move externally if it grows