fix(git): fixed strip command to always require a valid branch name for git.
unless specific branch is given git strip doesn't really work fine
This commit is contained in:
parent
31fa9ea6e4
commit
9f37558774
3 changed files with 47 additions and 18 deletions
|
|
@ -53,15 +53,17 @@ class RepoStripView(RepoAppView):
|
|||
data = {}
|
||||
rp = self.request.POST
|
||||
for i in range(1, 11):
|
||||
chset = 'changeset_id-%d' % (i,)
|
||||
check = rp.get(chset)
|
||||
changeset_id_key = f'changeset_id-{i}'
|
||||
changeset_id_branch_key = f'changeset_id_branch-{i}'
|
||||
check = rp.get(changeset_id_key)
|
||||
|
||||
if check:
|
||||
data[i] = self.db_repo.get_commit(rp[chset])
|
||||
data[i] = self.db_repo.get_commit(rp[changeset_id_key])
|
||||
if isinstance(data[i], EmptyCommit):
|
||||
data[i] = {'rev': None, 'commit': h.escape(rp[chset])}
|
||||
data[i] = {'rev': None, 'commit': h.escape(rp[changeset_id_key])}
|
||||
else:
|
||||
data[i] = {'rev': data[i].raw_id, 'branch': data[i].branch,
|
||||
rp_branch = rp.get(changeset_id_branch_key)
|
||||
data[i] = {'rev': data[i].raw_id, 'branch': data[i].branch or rp_branch,
|
||||
'author': h.escape(data[i].author),
|
||||
'comment': h.escape(data[i].message)}
|
||||
else:
|
||||
|
|
@ -78,6 +80,7 @@ class RepoStripView(RepoAppView):
|
|||
user = self._rhodecode_user
|
||||
rp = self.request.POST
|
||||
data = {}
|
||||
|
||||
for idx in rp:
|
||||
commit = json.loads(rp[idx])
|
||||
# If someone put two times the same branch
|
||||
|
|
@ -98,5 +101,5 @@ class RepoStripView(RepoAppView):
|
|||
except Exception as e:
|
||||
data[commit['rev']] = False
|
||||
log.debug('Stripped commit %s from repo `%s` failed by %s, exeption %s',
|
||||
commit['rev'], self.db_repo_name, user, e.message)
|
||||
commit['rev'], self.db_repo_name, user, e)
|
||||
return data
|
||||
|
|
|
|||
|
|
@ -583,9 +583,12 @@ class GitRepository(BaseRepository):
|
|||
if commit.merge:
|
||||
raise Exception('Cannot reset to merge commit')
|
||||
|
||||
if not branch_name:
|
||||
raise ValueError(f'git strip requires a valid branch name, got {branch_name} instead')
|
||||
|
||||
# parent is going to be the new head now
|
||||
commit = commit.parents[0]
|
||||
self._remote.set_refs('refs/heads/%s' % branch_name, commit.raw_id)
|
||||
self._remote.update_refs(f'refs/heads/{branch_name}', commit.raw_id)
|
||||
|
||||
# clear cached properties
|
||||
self._invalidate_prop_cache('commit_ids')
|
||||
|
|
|
|||
|
|
@ -14,6 +14,12 @@
|
|||
<div id="box-1" class="inputx locked_input">
|
||||
<input class="text" id="changeset_id-1" name="changeset_id-1" size="59"
|
||||
placeholder="${_('Enter full 40 character commit sha')}" type="text" value="">
|
||||
|
||||
%if c.rhodecode_db_repo.repo_type == 'git':
|
||||
<input class="text" id="changeset_id_branch-1" name="changeset_id_branch-1" size="30"
|
||||
placeholder="${_('Enter name of branch')}" type="text" value="">
|
||||
%endif
|
||||
|
||||
<div id="plus_icon-1" class="btn btn-default plus_input_button" onclick="addNew(1);return false">
|
||||
<i class="icon-plus">${_('Add another commit')}</i>
|
||||
</div>
|
||||
|
|
@ -47,16 +53,32 @@ addNew = function(number){
|
|||
$('#plus_icon-'+number).detach();
|
||||
number++;
|
||||
|
||||
var input = '<div id="box-'+number+'" class="inputx locked_input">'+
|
||||
'<input class="text" id="changeset_id-'+number+'" name="changeset_id-'+number+'" size="59" type="text" value=""' +
|
||||
'placeholder="${_('Enter full 40 character commit sha')}">'+
|
||||
'<div id="plus_icon-'+number+'" class="btn btn-default plus_input_button" onclick="addNew('+number+');return false">'+
|
||||
'<i class="icon-plus">${_('Add another commit')}</i>'+
|
||||
'</div>'+
|
||||
'<div id="minus_icon-'+number+'" class="btn btn-default minus_input_button" onclick="delOld('+(number)+');return false">'+
|
||||
%if c.rhodecode_db_repo.repo_type == 'git':
|
||||
var input = '<div id="box-' + number + '" class="inputx locked_input">' +
|
||||
'<input class="text" id="changeset_id-' + number + '" name="changeset_id-' + number + '" size="59" type="text" value=""' +
|
||||
'placeholder="${_('Enter full 40 character commit sha')}">' +
|
||||
'<input class="text" id="changeset_id_branch-' + number + '" name="changeset_id_branch-' + number + '" size="30" type="text" value=""' +
|
||||
'placeholder="${_('Enter name of branch')}">' +
|
||||
'<div id="plus_icon-' + number + '" class="btn btn-default plus_input_button" onclick="addNew(' + number + ');return false">' +
|
||||
'<i class="icon-plus">${_('Add another commit')}</i>' +
|
||||
'</div>' +
|
||||
'<div id="minus_icon-' + number + '" class="btn btn-default minus_input_button" onclick="delOld(' + (number) + ');return false">' +
|
||||
minus +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
'</div>' +
|
||||
'</div>';
|
||||
%else:
|
||||
var input = '<div id="box-'+number+'" class="inputx locked_input">'+
|
||||
'<input class="text" id="changeset_id-'+number+'" name="changeset_id-'+number+'" size="59" type="text" value=""' +
|
||||
'placeholder="${_('Enter full 40 character commit sha')}">'+
|
||||
'<div id="plus_icon-'+number+'" class="btn btn-default plus_input_button" onclick="addNew('+number+');return false">'+
|
||||
'<i class="icon-plus">${_('Add another commit')}</i>'+
|
||||
'</div>'+
|
||||
'<div id="minus_icon-'+number+'" class="btn btn-default minus_input_button" onclick="delOld('+(number)+');return false">'+
|
||||
minus +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
%endif
|
||||
|
||||
$('#change_body').append(input);
|
||||
plus_leaf++;
|
||||
};
|
||||
|
|
@ -135,12 +157,13 @@ checkCommits = function() {
|
|||
'{1}' +
|
||||
'<div style="white-space:pre">' +
|
||||
'author: {2}\n' +
|
||||
'description: {3}' +
|
||||
'description: {3}\n' +
|
||||
'branch: {4}' +
|
||||
'</div>' +
|
||||
'</li>').format(
|
||||
value.rev,
|
||||
"${_(' commit verified positive')}",
|
||||
value.author, value.comment
|
||||
value.author, value.comment, value.branch
|
||||
);
|
||||
result += verifiedHtml;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue