##// END OF EJS Templates
fix(git): fixed strip command to always require a valid branch name for git....
super-admin -
r5253:65ddf04b default
parent child Browse files
Show More
@@ -53,15 +53,17 b' class RepoStripView(RepoAppView):'
53 53 data = {}
54 54 rp = self.request.POST
55 55 for i in range(1, 11):
56 chset = 'changeset_id-%d' % (i,)
57 check = rp.get(chset)
56 changeset_id_key = f'changeset_id-{i}'
57 changeset_id_branch_key = f'changeset_id_branch-{i}'
58 check = rp.get(changeset_id_key)
58 59
59 60 if check:
60 data[i] = self.db_repo.get_commit(rp[chset])
61 data[i] = self.db_repo.get_commit(rp[changeset_id_key])
61 62 if isinstance(data[i], EmptyCommit):
62 data[i] = {'rev': None, 'commit': h.escape(rp[chset])}
63 data[i] = {'rev': None, 'commit': h.escape(rp[changeset_id_key])}
63 64 else:
64 data[i] = {'rev': data[i].raw_id, 'branch': data[i].branch,
65 rp_branch = rp.get(changeset_id_branch_key)
66 data[i] = {'rev': data[i].raw_id, 'branch': data[i].branch or rp_branch,
65 67 'author': h.escape(data[i].author),
66 68 'comment': h.escape(data[i].message)}
67 69 else:
@@ -78,6 +80,7 b' class RepoStripView(RepoAppView):'
78 80 user = self._rhodecode_user
79 81 rp = self.request.POST
80 82 data = {}
83
81 84 for idx in rp:
82 85 commit = json.loads(rp[idx])
83 86 # If someone put two times the same branch
@@ -98,5 +101,5 b' class RepoStripView(RepoAppView):'
98 101 except Exception as e:
99 102 data[commit['rev']] = False
100 103 log.debug('Stripped commit %s from repo `%s` failed by %s, exeption %s',
101 commit['rev'], self.db_repo_name, user, e.message)
104 commit['rev'], self.db_repo_name, user, e)
102 105 return data
@@ -583,9 +583,12 b' class GitRepository(BaseRepository):'
583 583 if commit.merge:
584 584 raise Exception('Cannot reset to merge commit')
585 585
586 if not branch_name:
587 raise ValueError(f'git strip requires a valid branch name, got {branch_name} instead')
588
586 589 # parent is going to be the new head now
587 590 commit = commit.parents[0]
588 self._remote.set_refs('refs/heads/%s' % branch_name, commit.raw_id)
591 self._remote.update_refs(f'refs/heads/{branch_name}', commit.raw_id)
589 592
590 593 # clear cached properties
591 594 self._invalidate_prop_cache('commit_ids')
@@ -14,6 +14,12 b''
14 14 <div id="box-1" class="inputx locked_input">
15 15 <input class="text" id="changeset_id-1" name="changeset_id-1" size="59"
16 16 placeholder="${_('Enter full 40 character commit sha')}" type="text" value="">
17
18 %if c.rhodecode_db_repo.repo_type == 'git':
19 <input class="text" id="changeset_id_branch-1" name="changeset_id_branch-1" size="30"
20 placeholder="${_('Enter name of branch')}" type="text" value="">
21 %endif
22
17 23 <div id="plus_icon-1" class="btn btn-default plus_input_button" onclick="addNew(1);return false">
18 24 <i class="icon-plus">${_('Add another commit')}</i>
19 25 </div>
@@ -47,16 +53,32 b' addNew = function(number){'
47 53 $('#plus_icon-'+number).detach();
48 54 number++;
49 55
50 var input = '<div id="box-'+number+'" class="inputx locked_input">'+
51 '<input class="text" id="changeset_id-'+number+'" name="changeset_id-'+number+'" size="59" type="text" value=""' +
52 'placeholder="${_('Enter full 40 character commit sha')}">'+
53 '<div id="plus_icon-'+number+'" class="btn btn-default plus_input_button" onclick="addNew('+number+');return false">'+
54 '<i class="icon-plus">${_('Add another commit')}</i>'+
55 '</div>'+
56 '<div id="minus_icon-'+number+'" class="btn btn-default minus_input_button" onclick="delOld('+(number)+');return false">'+
56 %if c.rhodecode_db_repo.repo_type == 'git':
57 var input = '<div id="box-' + number + '" class="inputx locked_input">' +
58 '<input class="text" id="changeset_id-' + number + '" name="changeset_id-' + number + '" size="59" type="text" value=""' +
59 'placeholder="${_('Enter full 40 character commit sha')}">' +
60 '<input class="text" id="changeset_id_branch-' + number + '" name="changeset_id_branch-' + number + '" size="30" type="text" value=""' +
61 'placeholder="${_('Enter name of branch')}">' +
62 '<div id="plus_icon-' + number + '" class="btn btn-default plus_input_button" onclick="addNew(' + number + ');return false">' +
63 '<i class="icon-plus">${_('Add another commit')}</i>' +
64 '</div>' +
65 '<div id="minus_icon-' + number + '" class="btn btn-default minus_input_button" onclick="delOld(' + (number) + ');return false">' +
57 66 minus +
58 '</div>' +
59 '</div>';
67 '</div>' +
68 '</div>';
69 %else:
70 var input = '<div id="box-'+number+'" class="inputx locked_input">'+
71 '<input class="text" id="changeset_id-'+number+'" name="changeset_id-'+number+'" size="59" type="text" value=""' +
72 'placeholder="${_('Enter full 40 character commit sha')}">'+
73 '<div id="plus_icon-'+number+'" class="btn btn-default plus_input_button" onclick="addNew('+number+');return false">'+
74 '<i class="icon-plus">${_('Add another commit')}</i>'+
75 '</div>'+
76 '<div id="minus_icon-'+number+'" class="btn btn-default minus_input_button" onclick="delOld('+(number)+');return false">'+
77 minus +
78 '</div>' +
79 '</div>';
80 %endif
81
60 82 $('#change_body').append(input);
61 83 plus_leaf++;
62 84 };
@@ -135,12 +157,13 b' checkCommits = function() {'
135 157 '{1}' +
136 158 '<div style="white-space:pre">' +
137 159 'author: {2}\n' +
138 'description: {3}' +
160 'description: {3}\n' +
161 'branch: {4}' +
139 162 '</div>' +
140 163 '</li>').format(
141 164 value.rev,
142 165 "${_(' commit verified positive')}",
143 value.author, value.comment
166 value.author, value.comment, value.branch
144 167 );
145 168 result += verifiedHtml;
146 169 }
General Comments 0
You need to be logged in to leave comments. Login now