@@ -159,6 +159,18 @@ gerrit-download is used."
159
159
" 'project (the project name)"
160
160
)
161
161
162
+ ; ; TODO document this variable
163
+ ; ; (setq gerrit-project-to-local-workspace-alist
164
+ ; ; '(
165
+ ; ; (("software/pro1" . "branch1") . "~/sandbox/pro1")
166
+ ; ; (("software/pro2" . "branch2") . "~/sandbox/pro2")
167
+ ; ; ))
168
+ (defvar gerrit-project-to-local-workspace-alist nil )
169
+
170
+ ; ; TODO docs missing
171
+ ; ; mention (project:A OR project:B OR project:C)
172
+ (defvar gerrit-interesting-open-changes-filter " is:open" )
173
+
162
174
(defun gerrit-download-format-change (change )
163
175
(let (columns)
164
176
; ; can this be implemented in an easier way?
@@ -215,6 +227,7 @@ This refspec is a string of the form 'refs/changes/xx/xx/x'.
215
227
; ; (e.g. if ssh-add was not called) this async call runs
216
228
; ; magit-process-password-prompt-regexps (used in magit-process-filter)
217
229
; ; which is called in magit-start-process
230
+ ; ; (see https://github.com/magit/magit/issues/4323)
218
231
(magit-run-git-async " fetch"
219
232
(gerrit-get-remote)
220
233
(gerrit-download--get-refspec change-metadata))
@@ -1215,6 +1228,7 @@ gerrit-upload: (current cmd: %(concat (gerrit-upload-create-git-review-cmd)))
1215
1228
1216
1229
(defun gerrit--select-change-from-matching-changes (search-string )
1217
1230
; ; see https://gerrit-review.googlesource.com/Documentation/user-search.html
1231
+ ; ; clients can let-bind `gerrit-change-singleline-columns'
1218
1232
(let* ((open-changes (seq-map #'reviewgerrit-download-format-change
1219
1233
(gerrit-rest-change-query
1220
1234
(or search-string " is:open" )
@@ -1228,15 +1242,49 @@ gerrit-upload: (current cmd: %(concat (gerrit-upload-create-git-review-cmd)))
1228
1242
" Download change with CHANGENR from the gerrit server."
1229
1243
(interactive
1230
1244
(list
1231
- (gerrit--select-change-from-matching-changes
1232
- (concat " status:open project:"
1233
- (gerrit-get-current-project)))))
1245
+ (let
1246
+ ((gerrit-change-singleline-columns '(number branch project subject)))
1247
+ (gerrit--select-change-from-matching-changes
1248
+ (concat " status:open project:"
1249
+ (gerrit-get-current-project))))))
1234
1250
1235
1251
(gerrit--init-accounts)
1236
1252
(if gerrit-use-gitreview-interface
1237
1253
(gerrit-download--gitreview changenr)
1238
1254
(gerrit-download--new changenr)))
1239
1255
1256
+ ; ; TODO split this up into two parts (one that downloads the change and one that opens the overview page using magit-show-commit
1257
+ (defun gerrit-download-and-open-overview (changenr )
1258
+ ; ; since a simple "is:open" query might return a lot of gerrit-changes, it
1259
+ ; ; is possible to filter the returned results by setting an variable
1260
+ ; ; called `gerrit-interesting-open-changes-filter' .
1261
+ (interactive (list
1262
+ (let
1263
+ ((gerrit-change-singleline-columns '(number branch project subject)))
1264
+ (gerrit--select-change-from-matching-changes
1265
+ gerrit-interesting-open-changes-filter))))
1266
+
1267
+ ; ; 1) get change metadata
1268
+ ; ; 2) determine workspace directory (based on branch and projectname)
1269
+ ; ; 3) switch to workspace
1270
+ ; ; 4) download change
1271
+ ; ; 5) display commit
1272
+ (let* ((change-metadata (car (gerrit-rest-change-query changenr)))
1273
+ (project-name (alist-get 'project change-metadata))
1274
+ (branch (alist-get 'branch change-metadata))
1275
+ (workspace-directory (or (cdr (assoc (cons project-name branch)
1276
+ gerrit-project-to-local-workspace-alist))
1277
+ ; ; TODO completion + write them to file
1278
+ (read-directory-name
1279
+ (format " Enter directory for project %s " project-name)))))
1280
+ (let ((default-directory workspace-directory))
1281
+ (message " changeinfo: name: %s , branch: %s -> workspace: %s "
1282
+ project-name branch workspace-directory)
1283
+ (gerrit-download changenr) ; ; this is async
1284
+ ; ; TODO run magit-show-commit
1285
+ ; ; only when the above change is downloaded to avoid window-flickering
1286
+ (magit-show-commit " HEAD" ))))
1287
+
1240
1288
(defun gerrit-upload ()
1241
1289
(interactive )
1242
1290
(if gerrit-use-gitreview-interface
0 commit comments