unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to streamline my Magit workflow?
@ 2022-10-29  7:43 Marcin Borkowski
  2022-10-29 11:18 ` Lele Gaifax
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Marcin Borkowski @ 2022-10-29  7:43 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

Hi all,

I am using Magit with BitBucket (don't judge me - my company uses BB,
I'd probably prefer something else).  When I push (with Magit, of
course), BitBucket responds with some info on the command line (I
suppose it uses Git hooks under the hood, but that is not important
here).  What is important is that I can parse that output to get the URL
I need to visit in my browser to open a pull request.

Now, I'd like to streamline my workflow.  Instead of pressing `$',
finding that URL and copying it to my browser, I'd like to either have
it done automatically after a push or triggered with a custom command.

So, my questions are:

1. How can I access the "magit process buffer" of the repo I'm in from
Elisp?

2. Is there some hook which runs after a (Magit) push is completed?

TIA,

-- 
Marcin Borkowski
http://mbork.pl



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to streamline my Magit workflow?
  2022-10-29  7:43 How to streamline my Magit workflow? Marcin Borkowski
@ 2022-10-29 11:18 ` Lele Gaifax
  2022-10-29 17:03 ` Kyle Meyer
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Lele Gaifax @ 2022-10-29 11:18 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Marcin,

never used, and maybe known to you already, but isn't this fulfilled by (or
buildable on top of) the Magit's Forge extension
(https://magit.vc/manual/forge/index.html)? It seems to (partially?)
support Bitbucket.

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele@metapensiero.it  |                 -- Fortunato Depero, 1929.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to streamline my Magit workflow?
  2022-10-29  7:43 How to streamline my Magit workflow? Marcin Borkowski
  2022-10-29 11:18 ` Lele Gaifax
@ 2022-10-29 17:03 ` Kyle Meyer
  2022-10-29 17:15 ` Björn Bidar
  2022-10-30  5:28 ` Peter Hardy
  3 siblings, 0 replies; 5+ messages in thread
From: Kyle Meyer @ 2022-10-29 17:03 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Help Gnu Emacs mailing list

Marcin Borkowski writes:

> Now, I'd like to streamline my workflow.  Instead of pressing `$',
> finding that URL and copying it to my browser, I'd like to either have
> it done automatically after a push or triggered with a custom command.
>
> So, my questions are:
>
> 1. How can I access the "magit process buffer" of the repo I'm in from
> Elisp?
>
> 2. Is there some hook which runs after a (Magit) push is completed?

To get something to fire once the process completes, you could latch
onto magit-process-sentinel (or magit-process-finish, which is called by
magit-process-sentinel).  For example, something like

  (defun my/magit-open-pr-after-push (process event)
    (when (and (memq (process-status process) '(exit signal))
               (= (process-exit-status process) 0))
      (let ((buf (process-buffer process))
            (section (process-get process 'section)))
        (when (buffer-live-p buf)
          (with-current-buffer buf
            (message "%s"
                     (buffer-substring-no-properties
                      (oref section content)
                      (oref section end))))))))
  
  (advice-add 'magit-process-sentinel :after #'my/magit-open-pr-after-push)

where (message ...) is replaced by code that calls browse-url if a PR
link is found.

You may want to also advise the particular magit-push-* command you use
to process-put a flag so the output search isn't triggered for other
async Magit commands.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to streamline my Magit workflow?
  2022-10-29  7:43 How to streamline my Magit workflow? Marcin Borkowski
  2022-10-29 11:18 ` Lele Gaifax
  2022-10-29 17:03 ` Kyle Meyer
@ 2022-10-29 17:15 ` Björn Bidar
  2022-10-30  5:28 ` Peter Hardy
  3 siblings, 0 replies; 5+ messages in thread
From: Björn Bidar @ 2022-10-29 17:15 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Help Gnu Emacs mailing list

Marcin Borkowski <mbork@mbork.pl> writes:

> I am using Magit with BitBucket (don't judge me - my company uses BB,
> I'd probably prefer something else).  When I push (with Magit, of
> course), BitBucket responds with some info on the command line (I
> suppose it uses Git hooks under the hood, but that is not important
> here).  What is important is that I can parse that output to get the URL
> I need to visit in my browser to open a pull request.

My company uses BB too, I usually just open the browser to create a PR.

> Now, I'd like to streamline my workflow.  Instead of pressing `$',
> finding that URL and copying it to my browser, I'd like to either have
> it done automatically after a push or triggered with a custom command.

I think the best that could be done is to extend magit-forge with BB
support, however there were some issues with that as BB has no support
to predict the PR refs. https://github.com/magit/forge/pull/198 

> 2. Is there some hook which runs after a (Magit) push is completed?

Yes BB runs a post-receive hook on their server to send you this
message.

Magit doesn't run any hook only git would do. But I think you mean
magit-hook, you could try C-h m RET and see if any of the hooks could
help you.

The best you can do is to parse the output of git push.

Br,

Björn Bidar



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to streamline my Magit workflow?
  2022-10-29  7:43 How to streamline my Magit workflow? Marcin Borkowski
                   ` (2 preceding siblings ...)
  2022-10-29 17:15 ` Björn Bidar
@ 2022-10-30  5:28 ` Peter Hardy
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Hardy @ 2022-10-30  5:28 UTC (permalink / raw)
  To: help-gnu-emacs

On Sat, 29 Oct 2022, at 6:43 PM, Marcin Borkowski wrote:
> Now, I'd like to streamline my workflow.  Instead of pressing `$',
> finding that URL and copying it to my browser, I'd like to either have
> it done automatically after a push or triggered with a custom command.

I'm not sure about properly parsing the bitbucket response, but I do have this in my init to make URLs in the process buffer clickable, which streamlines the process a little.

(add-hook 'magit-process-mode-hook #'goto-address-mode)

> 2. Is there some hook which runs after a (Magit) push is completed?

I didn't find anything useful when I was trying to solve this same problem. Ended up settling just for using goto-address-mode, at least until I have time/spoons to revisit it.

-- 
Peter



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-10-30  5:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-29  7:43 How to streamline my Magit workflow? Marcin Borkowski
2022-10-29 11:18 ` Lele Gaifax
2022-10-29 17:03 ` Kyle Meyer
2022-10-29 17:15 ` Björn Bidar
2022-10-30  5:28 ` Peter Hardy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).