Skip to content

Commit 5354ba2

Browse files
committed
Remove assignee related code
Since newer versions of gerrit have dropped support for the assignee in favor of an "attention-set", let's also drop support for setting/displaying the assigneeit in gerrit.el. Change-Id: If6571ca0b67479366e30e6d199f67774d444178f
1 parent d8dd983 commit 5354ba2

File tree

2 files changed

+11
-117
lines changed

2 files changed

+11
-117
lines changed

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ The function `gerrit-upload` uses the `transient` package and provides the
1717
following features in addition to uploading new changes (and new patchsets)
1818

1919
* specify reviewers
20-
* set an assignee
2120
* set a topic name
2221
* set WIP flag
2322
* set a ready-for-review flag
@@ -30,6 +29,11 @@ This code is tested using gerrit=3.8 and the gerrit version used on
3029

3130
## News
3231

32+
Jan 2025:
33+
34+
* Remove support for setting the assignee in `gerrit-upload`
35+
* Remove support for displaying and the asignee in the gerrit dashboard
36+
3337
March 2024:
3438

3539
* Renamed `gerrit-get-changeid-from-current-commit` to
@@ -210,7 +214,7 @@ If you want to create multiple dashboards you can create a dashboard using
210214
(interactive)
211215
(let ((gerrit-dashboard-query-alist
212216
'(
213-
("Waiting for +1" . "is:open assignee:groupX label:Code-Review=0")
217+
("Waiting for +1" . "is:open attention:groupX label:Code-Review=0")
214218
("Waiting for +2" . "is:open assignee:groupX label:Code-Review=1")
215219
)
216220
)

gerrit.el

+5-115
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
("Your turn" . "attention:self")
6161
("Work in progress" . "is:open owner:self is:wip")
6262
("Outgoing reviews" . "is:open owner:self -is:wip -is:ignored")
63-
("Incoming reviews" . "is:open -owner:self -is:wip -is:ignored (reviewer:self OR assignee:self)")
63+
("Incoming reviews" . "is:open -owner:self -is:wip -is:ignored (reviewer:self)")
6464
("CCed on" . "is:open -is:ignored cc:self")
6565
("Recently closed" . "is:closed -is:ignored (-is:wip OR owner:self) (owner:self OR reviewer:self OR assignee:self OR cc:self) limit:15"))
6666
"Query search string that is used for the data shown in the `gerrit-dashboard'.")
@@ -107,18 +107,6 @@ user names."
107107
(seq-map (lambda (account-entry) (alist-get 'username (cdr account-entry)))
108108
(gerrit-get-accounts-alist)))
109109

110-
(defun gerrit--read-assignee ()
111-
"Ask for the name of an assignee."
112-
(completing-read
113-
"Assignee: "
114-
(gerrit-get-usernames)
115-
nil ;; predicate
116-
t ;; require match
117-
nil ;; initial
118-
nil ;; hist (output only?)
119-
;; def
120-
nil))
121-
122110
(defun gerrit--get-protocol ()
123111
(if gerrit-use-ssl
124112
"https://"
@@ -343,45 +331,6 @@ This refspec is a string of the form \='refs/changes/xx/xx/x\='."
343331
(concat (gerrit--get-protocol) gerrit-host "/tools/hooks/commit-msg") hook-file)
344332
(set-file-modes hook-file #o755))))
345333

346-
(defun gerrit-push-and-assign (assignee &rest push-args)
347-
"Execute Git push with PUSH-ARGS and assign changes to ASSIGNEE.
348-
349-
A section in the respective process buffer is created."
350-
(interactive)
351-
(progn
352-
(apply #'magit-run-git-async "push" push-args)
353-
(set-process-sentinel
354-
magit-this-process
355-
(lambda (process event)
356-
(when (memq (process-status process) '(exit signal))
357-
(when (buffer-live-p (process-buffer process))
358-
(with-current-buffer (process-buffer process)
359-
(when-let* ((section (get-text-property (point) 'magit-section))
360-
(output (buffer-substring-no-properties
361-
(oref section content)
362-
(oref section end))))
363-
(if (not (zerop (process-exit-status process)))
364-
;; error
365-
(magit-process-sentinel process event)
366-
367-
;; success
368-
(process-put process 'inhibit-refresh t)
369-
370-
;; parse the output of "git push" and extract the change numbers. This
371-
;; information is used for setting the specified assignee
372-
;; Alternatively we could perform a gerrit query with owner:me and set the
373-
;; assignee for the latest change(s).
374-
(when assignee
375-
(if-let* ((matched-changes (s-match-strings-all "/\\+/[0-9]+" output)))
376-
(seq-do (lambda (x) (let ((changenr (s-chop-prefix "/+/" (car x))))
377-
(message "Setting assignee of %s to %s" changenr assignee)
378-
(gerrit-rest-change-set-assignee changenr assignee)
379-
(gerrit-magit-process-buffer-add-item
380-
(format "Assignee of change %s was set to %s" changenr assignee)
381-
"set-assignee" changenr)))
382-
matched-changes)))
383-
(magit-process-sentinel process event))))))))))
384-
385334
(defun gerrit-upload--get-refspec ()
386335
(concat "refs/for/" (gerrit-get-upstream-branch)))
387336

@@ -411,8 +360,7 @@ A section in the respective process buffer is created."
411360
(gerrit--ensure-commit-msg-hook-exists)
412361
;; TODO check that all to-be-uploaded commits have a changeid line
413362

414-
(let (assignee
415-
push-opts
363+
(let (push-opts
416364
no-verify
417365
(remote (gerrit-get-remote))
418366
(refspec (gerrit-upload--get-refspec)))
@@ -429,8 +377,6 @@ A section in the respective process buffer is created."
429377
;; TODO check that reviewers are valid (by checking that all
430378
;; reviewers don't contain a white-space)
431379
(push (concat "r=" reviewer) push-opts)))
432-
((s-starts-with? "assignee=" arg)
433-
(setq assignee (s-chop-prefix "assignee=" arg)))
434380
((s-starts-with? "topic=" arg)
435381
(push arg push-opts))
436382
((string= "ready" arg)
@@ -450,8 +396,9 @@ A section in the respective process buffer is created."
450396
(push "--no-verify" push-args))
451397
(push remote push-args)
452398
(push (concat "HEAD:" refspec) push-args)
453-
(apply #'gerrit-push-and-assign
454-
assignee
399+
400+
(apply #'magit-run-git-async
401+
"push"
455402
;; don't error when encountering local tags, which
456403
;; are absent from gerrit.
457404
"--no-follow-tags"
@@ -461,7 +408,6 @@ A section in the respective process buffer is created."
461408
"Transient used for uploading changes to gerrit"
462409
["Arguments"
463410
(gerrit-upload:--reviewers)
464-
(gerrit-upload:--assignee)
465411
("w" "Work in Progress" "wip")
466412
("v" "Ready for Review" "ready")
467413
(gerrit-upload:--topic)
@@ -502,35 +448,13 @@ which is not the same as nil."
502448
nil
503449
nil))
504450

505-
(transient-define-argument gerrit-upload:--assignee ()
506-
:description "Assignee"
507-
:class 'transient-option
508-
:key "a"
509-
:argument "assignee="
510-
:reader 'gerrit-upload:--read-assignee)
511-
512451
(transient-define-argument gerrit-upload:--topic ()
513452
:description "Topic"
514453
:class 'transient-option
515454
:key "t"
516455
:argument "topic="
517456
:reader 'gerrit-upload:--read-topic)
518457

519-
(defun gerrit-upload:--read-assignee (prompt _initial-input history)
520-
;; (gerrit--read-assignee) this doesn't update the history
521-
522-
;; using the history here doesn't have an effect (maybe it does, but for
523-
;; ivy-completing-read it doesn't)
524-
(completing-read
525-
prompt
526-
(gerrit-get-usernames)
527-
nil ;; predicate
528-
t ;; require match
529-
nil ;; initial ;; Maybe it makes sense to use the last/first history element here
530-
history ;; hist (output only?)
531-
;; def
532-
nil))
533-
534458
(defun gerrit-upload:--read-topic (prompt _initial-input history)
535459
(completing-read
536460
prompt
@@ -836,9 +760,6 @@ shown in the section buffer."
836760
("Subject" 55 t)
837761
("Status" 10 t)
838762
("Owner" 15 t)
839-
;; TODO remove this entry at runtime if the gerrit version > 3.4
840-
;; and the legacy assignee support is disabled
841-
;; ("Assignee" 15 t)
842763
("Reviewers" 25 nil)
843764
;; ("CC" 15 nil)
844765
("Repo" 24 t)
@@ -902,7 +823,6 @@ alist."
902823
(status . ,(alist-get 'status change)) ;; string
903824
;; alist-get 'owner => (_account_id . 1017133)
904825
(owner . ,(gerrit--alist-get-recursive 'owner '_account_id change))
905-
(assignee . ,(cdr (car (alist-get 'assignee change)))) ;; optional string
906826

907827
;; all account-ids of all users in the attention set
908828
(attention-set . ,(seq-map (lambda (attention-entry)
@@ -951,10 +871,6 @@ alist."
951871
;; displayed inside the dashboard
952872
(gerrit-rest-change-patch (button-get button 'change-id)))
953873

954-
(defun gerrit-dashboard--button-open-assignee-query (&optional button)
955-
(interactive)
956-
(gerrit-query (concat "assignee:" (button-get button 'assignee))))
957-
958874
(defun gerrit-dashboard--button-open-owner-query (&optional button)
959875
(interactive)
960876
(gerrit-query (concat "owner:" (button-get button 'owner))))
@@ -1003,15 +919,6 @@ alist."
1003919
action gerrit-dashboard--button-open-owner-query)
1004920
;; empty owner
1005921
"")))
1006-
("Assignee" (if-let* ((assignee
1007-
(alist-get (alist-get 'assignee change-metadata)
1008-
(gerrit-get-accounts-alist))))
1009-
`(,(propertize (alist-get 'name assignee) 'face 'magit-log-author)
1010-
assignee ,(alist-get 'username assignee)
1011-
follow-link t
1012-
action gerrit-dashboard--button-open-assignee-query)
1013-
;; empty assignee (not clickable)
1014-
""))
1015922
("Reviewers" (let ((attention-set (alist-get 'attention-set change-metadata))
1016923
(owner-account-id (alist-get 'owner change-metadata)))
1017924
;; TODO exclude the owner from the reviewers
@@ -1143,23 +1050,6 @@ locally and is referenced in
11431050
;; TODO interactively ask for vote + message
11441051
(gerrit-rest-topic-set-cr-vote (gerrit-dashboard--topic) "+2" ""))
11451052

1146-
(defun gerrit-dashboard-assign-change ()
1147-
"Set assignee of the change under point."
1148-
(interactive)
1149-
(let ((change-number (gerrit-dashboard--entry-number))
1150-
(assignee (gerrit--read-assignee)))
1151-
(message "setting assignee of change %s to %s" change-number assignee)
1152-
(gerrit-rest-change-set-assignee change-number assignee)
1153-
;; refresh dashboard
1154-
(gerrit-dashboard--refresh--and-point-restore)))
1155-
1156-
(defun gerrit-dashboard-assign-change-to-me ()
1157-
"Set assignee of the change under point."
1158-
(interactive)
1159-
(gerrit-rest-change-set-assignee (gerrit-dashboard--entry-number) "self")
1160-
;; refresh dashboard
1161-
(gerrit-dashboard--refresh--and-point-restore))
1162-
11631053
(defun gerrit-dashboard--get-list-entries ()
11641054
"Get the all entries used for \"tabulated-list-entries\"."
11651055
(seq-reduce (lambda (acc conscell)

0 commit comments

Comments
 (0)