Skip to content

Commit

Permalink
Fixing deletion bug
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentheirendt committed Mar 1, 2018
1 parent f6e9a7d commit 8681281
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
9 changes: 8 additions & 1 deletion src/checkRemoteBranchExistence.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@

global gitConf

% remove .git from the remoteRepoURL
if strcmpi(gitConf.remoteRepoURL(end-3:end), '.git')
tmpRepoName = gitConf.remoteRepoURL(1:end-4);
else
tmpRepoName = gitConf.remoteRepoURL;
end

% retrieve a list of all the branches
[status_curl, result_curl] = system(['curl -s -k --head ' gitConf.remoteRepoURL '/tree/' branchName]);
[status_curl, result_curl] = system(['curl -s -k --head ' tmpRepoName '/tree/' branchName]);

if status_curl == 0 && ~isempty(strfind(result_curl, '200 OK'))
printMsg(mfilename, ['The branch <' branchName '> exists remotely.']);
Expand Down
17 changes: 11 additions & 6 deletions src/deleteContribution.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,16 @@ function deleteContribution(branchName)
reply = input([gitCmd.lead, originCall, 'Are you sure that you want to delete the feature (branch) <', branchName, '>? YES/NO [NO]: '], 's');

if strcmpi(reply, 'yes') % users MUST enter 'yes', not only 'y'
% checkout the develop branch
checkoutBranch('develop');

% check if the develop branch exists remotely
if checkRemoteBranchExistence('develop')
mainBranch = 'develop';
else
mainBranch = 'master'; % fall back to master, which always exists
end

% checkout the develop branch
checkoutBranch(mainBranch);

% retrieve a list of all the branches
if ispc
Expand Down Expand Up @@ -65,11 +73,8 @@ function deleteContribution(branchName)
error([gitCmd.lead, ' [', mfilename,'] The list of features (branches) could not be retrieved.', gitCmd.fail]);
end

% check if branch exists remotely
[status_curl, result_curl] = system(['curl -s -k --head ', gitConf.remoteServerName, gitConf.userName, '/', gitConf.remoteRepoName, '/tree/', branchName]);

% delete the remote branch
if status_curl == 0 && ~isempty(strfind(result_curl, '200 OK'))
if checkRemoteBranchExistence(branchName)

[status_gitPush, result_gitPush] = system(['git push origin --delete ', branchName]);

Expand Down

0 comments on commit 8681281

Please sign in to comment.