@@ -10,6 +10,7 @@ function deleteContribution(branchName)
10
10
%
11
11
% .. Author:
12
12
% - Laurent Heirendt
13
+ % - Agnieszka Wegrzyn fix upstream/origin branch removal
13
14
14
15
global gitConf
15
16
global gitCmd
@@ -74,18 +75,50 @@ function deleteContribution(branchName)
74
75
end
75
76
76
77
% delete the remote branch
77
- if checkRemoteBranchExistence(branchName )
78
+ [branchExists_up , branchExists_org ] = checkRemoteBranchExistence(branchName );
79
+
80
+ if branchExists_org
81
+ reply = ' ' ;
78
82
79
- [ status_gitPush , result_gitPush ] = system([ ' git push origin --delete ' , branchName ]);
83
+ while isempty( reply ) || ~strcmpi( reply , ' yes ' )
80
84
81
- if status_gitPush == 0
82
- fprintf([gitCmd .lead , originCall , ' The remote <' , branchName , ' > branch has been deleted.' , gitCmd .success , gitCmd .trail ]);
83
- else
84
- fprintf(result_gitPush );
85
- error([gitCmd .lead , ' [' , mfilename ,' ] The remote <' , branchName ,' > branch could not be deleted.' , gitCmd .fail ]);
85
+ reply = input([gitCmd .lead , originCall , ' Are you sure that you want to delete the branch <' , branchName , ' > on ORIGIN? YES/NO [NO]: ' ], ' s' );
86
+
87
+ if strcmpi(reply , ' yes' ) % users MUST enter 'yes', not only 'y'
88
+ [status_gitPush , result_gitPush ] = system([' git push origin --delete ' , branchName ]);
89
+
90
+ if status_gitPush == 0
91
+ fprintf([gitCmd .lead , originCall , ' The remote (origin) <' , branchName , ' > branch has been deleted.' , gitCmd .success , gitCmd .trail ]);
92
+ else
93
+ fprintf(result_gitPush );
94
+ error([gitCmd .lead , ' [' , mfilename ,' ] The remote (origin) <' , branchName ,' > branch could not be deleted.' , gitCmd .fail ]);
95
+ end
96
+ end
97
+ end
98
+ else
99
+ fprintf([gitCmd .lead , originCall , ' The remote (origin) <' , branchName ,' > branch does not exist.' , gitCmd .fail , gitCmd .trail ]);
100
+ end
101
+
102
+ if branchExists_up
103
+ reply = ' ' ;
104
+
105
+ while isempty(reply ) || ~strcmpi(reply , ' yes' )
106
+
107
+ reply = input([gitCmd .lead , originCall , ' Are you sure that you want to delete the branch <' , branchName , ' > on UPSTREAM? YES/NO [NO]: ' ], ' s' );
108
+
109
+ if strcmpi(reply , ' yes' ) % users MUST enter 'yes', not only 'y'
110
+ [status_gitPush , result_gitPush ] = system([' git push upstream --delete ' , branchName ]);
111
+
112
+ if status_gitPush == 0
113
+ fprintf([gitCmd .lead , originCall , ' The remote (upstream) <' , branchName , ' > branch has been deleted.' , gitCmd .success , gitCmd .trail ]);
114
+ else
115
+ fprintf(result_gitPush );
116
+ error([gitCmd .lead , ' [' , mfilename ,' ] The remote (upstream) <' , branchName ,' > branch could not be deleted.' , gitCmd .fail ]);
117
+ end
118
+ end
86
119
end
87
120
else
88
- fprintf([gitCmd .lead , originCall , ' The remote <' , branchName ,' > branch does not exist.' , gitCmd .fail , gitCmd .trail ]);
121
+ fprintf([gitCmd .lead , originCall , ' The remote (upstream) <' , branchName ,' > branch does not exist.' , gitCmd .fail , gitCmd .trail ]);
89
122
end
90
123
end
91
124
end
0 commit comments