Skip to content

Commit

Permalink
Changes to documentation of install functions
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentheirendt committed Aug 4, 2017
1 parent c12505c commit fa3a4e7
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 43 deletions.
10 changes: 7 additions & 3 deletions src/base/install/getGitBashVersion.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
function [installedVersion, installedVersionNum] = getGitBashVersion()
% determine the version of gitBash. This function can only be run on Windows,
% and throws an error when run on a UNIX system.
% On Windows, this function determines the version of gitBash.
% This function can only be run on Windows, and throws an error when run on a UNIX system.
%
% USAGE:
% installGitBash()
% [installedVersion, installedVersionNum] = getGitBashVersion()
%
% OUTPUT:
% installedVersion: String of installed version of gitBash in the form `2.13.2`
% installedVersionNum: Integer of `installedVersion`, e.g. `2132`
%

global CBTDIR
Expand Down
4 changes: 2 additions & 2 deletions src/base/install/installGitBash.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function [] = installGitBash()
% Wraps the installer for PortableGit and checks for available updates
% THis function can only be run on Windows, and throws an error when run on a UNIX system.
% This function wraps the installer for PortableGit and checks for available updates.
% This function can only be run on Windows, and throws an error when run on a UNIX system.
%
% USAGE:
% installGitBash()
Expand Down
74 changes: 40 additions & 34 deletions src/base/install/portableGitSetup.m
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
function [] = portableGitSetup(gitBashVersion, removeFlag)
% Downloads the latest version of PortableGit on Windows (archive), extracts the folder
% and moves them to the hidden .tmp folder. This function only runs on Windows, and throws
% an error when run on a UNIX system.
% This function downloads the latest version of PortableGit on Windows (archive), extracts the folder
% and moves the contents to the hidden .tmp folder in a folder called `PortableGit-a.bc.c`
% This function can only be run on Windows, and throws an error when run on a UNIX system.
%
% USAGE:
% portableGitSetup(gitBashVersion, removeFlag)
%
% INPUT:
% removeFlag: - 0: install, don't remove anything
% - 1: install, remove every old version
% - 2: don't install, remove every old version (folders)
% - 3: don't install, remove folders and .exe files
% removeFlag: Flag to remove old versions from the path or not
%
% - 0: install, don't remove anything
% - 1: install, remove paths in registry
% - 2: don't install gitBash, remove .exe file and paths in registry
% - 3: don't install gitBash, remove everything including unpacked archives (to be implemented)
%
% .. The folders of PortableGit in .tmp should not be removed in a MATLAB live session
% as they may be linked to the MATLAB thread.

global CBTDIR

Expand Down Expand Up @@ -64,8 +69,8 @@
movefile(fileNamePortableGitwoVersion, fileNamePortableGit)
end

% remove a previous version
if removeFlag > 0
% remove a previous version by unsetting eventual paths
if removeFlag >= 1
% unset the paths
for i = 1:length(pathPortableGitFragments)
% global machine path
Expand All @@ -81,9 +86,9 @@
end

% extract the archive and set the paths
if removeFlag < 2
if exist(fileNamePortableGit, 'file') == 2
if exist(fileNamePortableGit, 'file') == 2

if removeFlag <= 2
% extract the archive
fprintf(' > Extracting the gitBash archive (this may take a while) ...');
system([fileNamePortableGit ' -y']);
Expand All @@ -94,34 +99,35 @@
catch
fprintf([' > gitBash folder (', strrep(pathPortableGit, '\', '\\'), ') could not be renamed.\n']);
end
% remove the downloaded file
if removeFlag == 3
try
delete(fileNamePortableGit);
fprintf([' > gitBash archive (', fileNamePortableGit, ') removed.\n']);
catch
fprintf([' > gitBash archive (', fileNamePortableGit, ') could not be removed.\n']);
end
end

% remove the downloaded file
if removeFlag >= 2
try
delete(fileNamePortableGit);
fprintf([' > gitBash archive (', fileNamePortableGit, ') removed.\n']);
catch
fprintf([' > gitBash archive (', fileNamePortableGit, ') could not be removed.\n']);
end
end

% set the path machine wide
for i = 1:length(pathPortableGitFragments)
if isempty(strfind(getsysenvironvar('Path'), pathPortableGitFragments{i}))
setsysenvironvar('Path', [pathPortableGitFragments{i} ';' getsysenvironvar('Path')]);
end
if isempty(strfind(getenv('Path'), pathPortableGitFragments{i}))
setenv('Path', [pathPortableGitFragments{i} ';' getenv('Path') ]);
end
% set the path machine wide
for i = 1:length(pathPortableGitFragments)
if isempty(strfind(getsysenvironvar('Path'), pathPortableGitFragments{i}))
setsysenvironvar('Path', [pathPortableGitFragments{i} ';' getsysenvironvar('Path')]);
end
if isempty(strfind(getenv('Path'), pathPortableGitFragments{i}))
setenv('Path', [pathPortableGitFragments{i} ';' getenv('Path') ]);
end
end

% add the path to the MATLABPATH
addpath(genpath(pathPortableGit));
% add the path to the MATLABPATH
addpath(genpath(pathPortableGit));

% print a success message
fprintf(' > gitBash successfully installed.\n');
else
error('Portable gitBash cannot be downloaded. Check your internet connection.');
end
% print a success message
fprintf(' > gitBash successfully installed.\n');
else
error('Portable gitBash cannot be downloaded. Check your internet connection.');
end

% jump back to the old directory
Expand Down
4 changes: 2 additions & 2 deletions src/base/install/updateCobraToolbox.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
% and asks the user to update The COBRA Toolbox (updates the develop and master branches)
%
% USAGE:
% updateCobraToolbox();
% updateCobraToolbox()
%
% INPUT:
% fetchAndCheckOnly: if set to true, the repository is not updated (default: false)
% fetchAndCheckOnly: if set to true, the repository is not updated but only new commits are fetched (default: false)
%

if nargin < 1
Expand Down
8 changes: 6 additions & 2 deletions src/base/install/updateGitBash.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
function [] = updateGitBash(fetchAndCheckOnly)
% On windows, update the version of gitBash. On UNIX, this function throws an error
% On windows, this function updates the already existing version of gitBash.
% This function can only be run on Windows, and throws an error when run on a UNIX system.
%
% USAGE:
% updateGitBash(fetchAndCheckOnly)
%
% INPUT:
% fetchAndCheckOnly: if set to true, gitBash is not updated (default: false)
% fetchAndCheckOnly: if set to `true`, gitBash is not updated, but only a check is made (default: `false`)
%

global CBTDIR
Expand Down

0 comments on commit fa3a4e7

Please sign in to comment.