magit / forge

Work with Git forges from the comfort of Magit
GNU General Public License v3.0
1.33k stars 117 forks source link

forge-create-issue produces a confusing error when repo has no clone #722

Open bcc32 opened 1 month ago

bcc32 commented 1 month ago

When attempting to create an issue for a repo that has been added to forge but which has no local clone, the error produced is confusing:

Creating directory: Permission denied, /magit

It seems to be attempting to create a directory to store the draft issue text, which makes sense, but the error itself is a little unclear and it would probably be a nicer experience to handle this case specifically and produce a user-error.

Steps to reproduce are just:

  1. M-x forge-add-repository and specify some GitHub repo you don't have a clone for. I used djcb/mu.
  2. M-x forge-list-repositories and go to the topics page for that newly-added repo.
  3. M-x forge-create-issue, which errors with the message mentioned above.

Backtrace follows:

Debugger entered--Lisp error: (permission-denied "Creating directory" "Permission denied" "/magit")
  transient--exit-and-debug(error (permission-denied "Creating directory" "Permission denied" "/magit"))
  signal(permission-denied ("Creating directory" "Permission denied" "/magit"))
  files--ensure-directory(make-directory-internal "/magit")
  make-directory("/magit/posts/" t)
  forge--prepare-post-buffer("new-issue" "Create new issue on djcb/mu")
  #<subr forge-create-issue>()
  apply(#<subr forge-create-issue> nil)
  #f(compiled-function (fn &rest args) #<bytecode 0x10411af0915d810c>)(#<subr forge-create-issue>)
  apply(#f(compiled-function (fn &rest args) #<bytecode 0x10411af0915d810c>) #<subr forge-create-issue> nil)
  (lambda (fn &rest args) (interactive #f(compiled-function (spec) #<bytecode 0x43d85eb2db5920d>)) (apply '#f(compiled-function (fn &rest args) #<bytecode 0x10411af0915d810c>) fn args))(#<subr forge-create-issue>)
  apply((lambda (fn &rest args) (interactive #f(compiled-function (spec) #<bytecode 0x43d85eb2db5920d>)) (apply '#f(compiled-function (fn &rest args) #<bytecode 0x10411af0915d810c>) fn args)) #<subr forge-create-issue> nil)
  forge-create-issue()
  funcall-interactively(forge-create-issue)
  command-execute(forge-create-issue)

FYI version info:

M-x magit-version RET

Magit 20241020.1608 [>= 20241020.1608], Transient 20241018.1740, Forge 20241018.1648, Git 2.44.1, Emacs 29.4, gnu/linux

tarsius commented 1 month ago

Yes, the errors could be improved and it is also worth looking into instead making it possible to create issues in such situations (and pull-requests, but that is both harder and stranger (where does the branch come from if there is no clone?)).

Additional work is arriving at a very high frequency right now, so I won't get to this soon.

bcc32 commented 1 month ago

No problem, thanks for the ack and all your amazing work on magit and forge!