Skip to content

Commit

Permalink
handles .git now, fixes #37
Browse files Browse the repository at this point in the history
  • Loading branch information
mobeets committed Nov 9, 2017
1 parent d2e188c commit e26ea42
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions mpm.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ function mpm(action, varargin)
% find url if not set
if isempty(pkg.url)
pkg.url = findUrl(pkg, opts);
else % checks for .git and replaces
pkg.url = handleCustomUrl(pkg.url);
end

% download package and add to metadata
Expand Down Expand Up @@ -107,13 +109,15 @@ function removePackage(pkg, opts)
pkgsToRm = pkgs(ix);
disp([' Removing ' num2str(sum(ix)) ' package(s) named ''' ...
pkg.name '''.']);
reply = input(' Confirm (y/n)? ', 's');
if isempty(reply)
reply = 'y';
end
if ~strcmpi(reply(1), 'y')
disp(' Forget I asked.');
return;
if ~opts.force
reply = input(' Confirm (y/n)? ', 's');
if isempty(reply)
reply = 'y';
end
if ~strcmpi(reply(1), 'y')
disp(' Forget I asked.');
return;
end
end
for ii = 1:numel(pkgsToRm)
pkg = pkgsToRm(ii);
Expand Down Expand Up @@ -153,6 +157,16 @@ function removePackage(pkg, opts)
opts.nopaths = false;
end

function url = handleCustomUrl(url)
% if .git url, must remove and add /zipball/master
inds = strfind(url, '.git');
if isempty(inds)
return;
end
ind = inds(end);
url = [url(1:ind-1) '/zipball/master' url(ind+4:end)];
end

function url = findUrl(pkg, opts)
% find url by searching matlab fileexchange and github given opts.name

Expand Down Expand Up @@ -263,7 +277,7 @@ function removePackage(pkg, opts)

isOk = unzipFromUrl(pkg);
if ~isOk
warning([' Could not install.']);
warning(' Could not install.');
return;
end
pkg.date_downloaded = datestr(datetime);
Expand Down Expand Up @@ -316,6 +330,7 @@ function removePackage(pkg, opts)
fnms = dir(fullfile(pkg.installdir, '*.m'));
if ~isempty(fnms)
mdir = ''; % all is well; *.m files exist in base directory
return;
else
M_DIR_ORDER = {'bin', 'src', 'lib', 'code'};
for ii = 1:numel(M_DIR_ORDER)
Expand Down

0 comments on commit e26ea42

Please sign in to comment.