##// 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 data = {}
53 data = {}
54 rp = self.request.POST
54 rp = self.request.POST
55 for i in range(1, 11):
55 for i in range(1, 11):
56 chset = 'changeset_id-%d' % (i,)
56 changeset_id_key = f'changeset_id-{i}'
57 check = rp.get(chset)
57 changeset_id_branch_key = f'changeset_id_branch-{i}'
58 check = rp.get(changeset_id_key)
58
59
59 if check:
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 if isinstance(data[i], EmptyCommit):
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 else:
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 'author': h.escape(data[i].author),
67 'author': h.escape(data[i].author),
66 'comment': h.escape(data[i].message)}
68 'comment': h.escape(data[i].message)}
67 else:
69 else:
@@ -78,6 +80,7 b' class RepoStripView(RepoAppView):'
78 user = self._rhodecode_user
80 user = self._rhodecode_user
79 rp = self.request.POST
81 rp = self.request.POST
80 data = {}
82 data = {}
83
81 for idx in rp:
84 for idx in rp:
82 commit = json.loads(rp[idx])
85 commit = json.loads(rp[idx])
83 # If someone put two times the same branch
86 # If someone put two times the same branch
@@ -98,5 +101,5 b' class RepoStripView(RepoAppView):'
98 except Exception as e:
101 except Exception as e:
99 data[commit['rev']] = False
102 data[commit['rev']] = False
100 log.debug('Stripped commit %s from repo `%s` failed by %s, exeption %s',
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 return data
105 return data
@@ -583,9 +583,12 b' class GitRepository(BaseRepository):'
583 if commit.merge:
583 if commit.merge:
584 raise Exception('Cannot reset to merge commit')
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 # parent is going to be the new head now
589 # parent is going to be the new head now
587 commit = commit.parents[0]
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 # clear cached properties
593 # clear cached properties
591 self._invalidate_prop_cache('commit_ids')
594 self._invalidate_prop_cache('commit_ids')
@@ -14,6 +14,12 b''
14 <div id="box-1" class="inputx locked_input">
14 <div id="box-1" class="inputx locked_input">
15 <input class="text" id="changeset_id-1" name="changeset_id-1" size="59"
15 <input class="text" id="changeset_id-1" name="changeset_id-1" size="59"
16 placeholder="${_('Enter full 40 character commit sha')}" type="text" value="">
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 <div id="plus_icon-1" class="btn btn-default plus_input_button" onclick="addNew(1);return false">
23 <div id="plus_icon-1" class="btn btn-default plus_input_button" onclick="addNew(1);return false">
18 <i class="icon-plus">${_('Add another commit')}</i>
24 <i class="icon-plus">${_('Add another commit')}</i>
19 </div>
25 </div>
@@ -47,6 +53,20 b' addNew = function(number){'
47 $('#plus_icon-'+number).detach();
53 $('#plus_icon-'+number).detach();
48 number++;
54 number++;
49
55
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">' +
66 minus +
67 '</div>' +
68 '</div>';
69 %else:
50 var input = '<div id="box-'+number+'" class="inputx locked_input">'+
70 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=""' +
71 '<input class="text" id="changeset_id-'+number+'" name="changeset_id-'+number+'" size="59" type="text" value=""' +
52 'placeholder="${_('Enter full 40 character commit sha')}">'+
72 'placeholder="${_('Enter full 40 character commit sha')}">'+
@@ -57,6 +77,8 b' addNew = function(number){'
57 minus +
77 minus +
58 '</div>' +
78 '</div>' +
59 '</div>';
79 '</div>';
80 %endif
81
60 $('#change_body').append(input);
82 $('#change_body').append(input);
61 plus_leaf++;
83 plus_leaf++;
62 };
84 };
@@ -135,12 +157,13 b' checkCommits = function() {'
135 '{1}' +
157 '{1}' +
136 '<div style="white-space:pre">' +
158 '<div style="white-space:pre">' +
137 'author: {2}\n' +
159 'author: {2}\n' +
138 'description: {3}' +
160 'description: {3}\n' +
161 'branch: {4}' +
139 '</div>' +
162 '</div>' +
140 '</li>').format(
163 '</li>').format(
141 value.rev,
164 value.rev,
142 "${_(' commit verified positive')}",
165 "${_(' commit verified positive')}",
143 value.author, value.comment
166 value.author, value.comment, value.branch
144 );
167 );
145 result += verifiedHtml;
168 result += verifiedHtml;
146 }
169 }
General Comments 0
You need to be logged in to leave comments. Login now