Skip to content
Snippets Groups Projects
Commit 157dfd08 authored by Christophe Bradley Smith's avatar Christophe Bradley Smith
Browse files

temp

parent db86113f
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@
% Prepare work space
clc
checkVersion()
% checkVersion()
% Check for miscelaneous transcriptions in the work space
miscLS = who('-regexp', '^ls.*[0-9]');
......@@ -108,50 +108,4 @@ for iTrial = 1:nTrials
setLabelValue(lss, iTrial, 'Words', ls.Labels.Words{iTrial}.ROILimits, ls.Labels.Words{iTrial}.Value)
end
end
%% Git managment
function checkVersion()
% Check if the current directory is a Git repository
if ~isGitRepository()
error('This is not a Git repository.');
end
% Fetch the latest changes from the remote repository
system('git fetch origin');
% Get the current branch name
[~, currentBranch] = system('git rev-parse --abbrev-ref HEAD');
currentBranch = strtrim(currentBranch);
% Get the local and remote commit hashes
localCommit = getGitCommitHash();
remoteCommit = getRemoteCommit_hash(currentBranch);
% Compare the local and remote commits
if strcmp(localCommit, remoteCommit)
disp('Your local branch is up-to-date with the remote branch.');
else
disp('WARNING: Your local branch is out of date with the remote.');
disp(['Local commit: ' localCommit]);
disp(['Remote commit: ' remoteCommit]);
disp('Please run "git pull" to update your local code.');
end
end
function isGit = isGitRepository()
% Check if the current directory is a Git repository by checking for the existence of a .git directory
isGit = exist('.git', 'dir') == 7;
end
function commitHash = getGitCommitHash()
% Get the commit hash of the current branch locally
[~, commitHash] = system('git rev-parse HEAD');
commitHash = strtrim(commitHash); % Remove any trailing newline or space
end
function remoteCommit = getRemoteCommit_hash(branch)
% Get the commit hash of the remote branch
[~, remoteCommit] = system(['git rev-parse origin/' branch]);
remoteCommit = strtrim(remoteCommit); % Remove any trailing newline or space
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment