Making sure that github/gitlab works with forge
To use this correctly, create entries in ~/.authinfo.gpg that contains
the API passwords from Github and Gitlab:
    machine api.github.com login howardabrams^forge password redacted
    machine gitlab.com/api/v4 login howardabrams^forge password redacted
Also, this change prompts us for comfirmation before pushing to the
main upstream branch (since you should want to use a pull request).
			
			
This commit is contained in:
		
							parent
							
								
									4ed8572a77
								
							
						
					
					
						commit
						414b56eb5f
					
				
					 1 changed files with 58 additions and 26 deletions
				
			
		| 
						 | 
					@ -1046,10 +1046,35 @@ Can not live without [[https://magit.vc/][Magit]], a Git porcelain for Emacs. I
 | 
				
			||||||
      "g c b" '("Branch"                   . magit-branch-and-checkout)))
 | 
					      "g c b" '("Branch"                   . magit-branch-and-checkout)))
 | 
				
			||||||
#+END_SRC
 | 
					#+END_SRC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The [[https://github.com/emacsmirror/git-timemachine][git-timemachine]] project is cool:
 | 
				
			||||||
 | 
					#+BEGIN_SRC emacs-lisp
 | 
				
			||||||
 | 
					(use-package git-timemachine
 | 
				
			||||||
 | 
					  :config
 | 
				
			||||||
 | 
					  (ha-leader "g t" '("git timemachine" . git-timemachine)))
 | 
				
			||||||
 | 
					#+END_SRC
 | 
				
			||||||
 | 
					*** Gist
 | 
				
			||||||
 | 
					Using the [[https://github.com/emacsmirror/gist][gist package]] to write code snippets on [[https://gist.github.com/][Github]] seems like it can be useful, but I'm not sure how often.
 | 
				
			||||||
 | 
					#+BEGIN_SRC emacs-lisp
 | 
				
			||||||
 | 
					   (use-package gist
 | 
				
			||||||
 | 
					     :config
 | 
				
			||||||
 | 
					     (ha-leader
 | 
				
			||||||
 | 
					       "g G" '(:ignore t :which-key "gists")
 | 
				
			||||||
 | 
					       "g l g" '("gists"          . gist-list)
 | 
				
			||||||
 | 
					       "g G l" '("list"           . gist-list)                     ; Lists your gists in a new buffer.
 | 
				
			||||||
 | 
					       "g G r" '("region"         . gist-region)                   ; Copies Gist URL into the kill ring.
 | 
				
			||||||
 | 
					       "g G R" '("private region" . gist-region-private)           ; Explicitly create a private gist.
 | 
				
			||||||
 | 
					       "g G b" '("buffer"         . gist-buffer)                   ; Copies Gist URL into the kill ring.
 | 
				
			||||||
 | 
					       "g G B" '("private buffer" . gist-buffer-private)           ; Explicitly create a private gist.
 | 
				
			||||||
 | 
					       "g c g" '("gist"           . gist-region-or-buffer)         ; Post either the current region, or buffer
 | 
				
			||||||
 | 
					       "g c G" '("private gist"   . gist-region-or-buffer-private))) ; create private gist from region or buffer
 | 
				
			||||||
 | 
					#+END_SRC
 | 
				
			||||||
 | 
					*** Forge
 | 
				
			||||||
Let's extend Magit with [[https://github.com/magit/forge][Magit Forge]] for working with Github and Gitlab:
 | 
					Let's extend Magit with [[https://github.com/magit/forge][Magit Forge]] for working with Github and Gitlab:
 | 
				
			||||||
#+BEGIN_SRC emacs-lisp
 | 
					#+BEGIN_SRC emacs-lisp
 | 
				
			||||||
  (use-package forge
 | 
					  (use-package forge
 | 
				
			||||||
    :after magit
 | 
					    :after magit
 | 
				
			||||||
 | 
					    :init
 | 
				
			||||||
 | 
					    (setq )
 | 
				
			||||||
    :config
 | 
					    :config
 | 
				
			||||||
    (ha-leader
 | 
					    (ha-leader
 | 
				
			||||||
      "g '"   '("Forge dispatch"           . forge-dispatch)
 | 
					      "g '"   '("Forge dispatch"           . forge-dispatch)
 | 
				
			||||||
| 
						 | 
					@ -1071,27 +1096,34 @@ Let's extend Magit with [[https://github.com/magit/forge][Magit Forge]] for work
 | 
				
			||||||
      "g c p" '("Pull request"             . forge-create-pullreq)))
 | 
					      "g c p" '("Pull request"             . forge-create-pullreq)))
 | 
				
			||||||
#+END_SRC
 | 
					#+END_SRC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
The [[https://github.com/emacsmirror/git-timemachine][git-timemachine]] project is cool:
 | 
					Every /so often/, pop over to the following URLs and generate a new
 | 
				
			||||||
#+BEGIN_SRC emacs-lisp
 | 
					token where the *Note* is =forge=, and then copy that into the
 | 
				
			||||||
(use-package git-timemachine
 | 
					[[file:~/.authinfo.gpg][~/.authinfo.gpg]]:
 | 
				
			||||||
  :config
 | 
					
 | 
				
			||||||
  (ha-leader "g t" '("git timemachine" . git-timemachine)))
 | 
					  - [[https://gitlab.com/-/profile/personal_access_tokens][Gitlab]]
 | 
				
			||||||
#+END_SRC
 | 
					  - [[https://github.com/settings/tokens][Github]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 and make sure this works:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Using the [[https://github.com/emacsmirror/gist][gist package]] to write code snippets on [[https://gist.github.com/][Github]] seems like it can be useful, but I'm not sure how often.
 | 
					 | 
				
			||||||
#+BEGIN_SRC emacs-lisp
 | 
					#+BEGIN_SRC emacs-lisp
 | 
				
			||||||
   (use-package gist
 | 
					  (ghub-request "GET" "/user" nil
 | 
				
			||||||
     :config
 | 
					                :forge 'github
 | 
				
			||||||
     (ha-leader
 | 
					                :host "api.github.com"
 | 
				
			||||||
       "g G" '(:ignore t :which-key "gists")
 | 
					                :username "howardabrams"
 | 
				
			||||||
       "g l g" '("gists"          . gist-list)
 | 
					                :auth 'forge)
 | 
				
			||||||
       "g G l" '("list"           . gist-list)                     ; Lists your gists in a new buffer.
 | 
					#+END_SRC
 | 
				
			||||||
       "g G r" '("region"         . gist-region)                   ; Copies Gist URL into the kill ring.
 | 
					*** Pushing is Bad
 | 
				
			||||||
       "g G R" '("private region" . gist-region-private)           ; Explicitly create a private gist.
 | 
					Pushing directly to the upstream branch is /bad form/, as one should create a pull request, etc. To prevent an accidental push, we /double-check/ first:
 | 
				
			||||||
       "g G b" '("buffer"         . gist-buffer)                   ; Copies Gist URL into the kill ring.
 | 
					
 | 
				
			||||||
       "g G B" '("private buffer" . gist-buffer-private)           ; Explicitly create a private gist.
 | 
					#+BEGIN_SRC emacs-lisp
 | 
				
			||||||
       "g c g" '("gist"           . gist-region-or-buffer)         ; Post either the current region, or buffer
 | 
					(define-advice magit-push-current-to-upstream (:before (args) query-yes-or-no)
 | 
				
			||||||
       "g c G" '("private gist"   . gist-region-or-buffer-private))) ; create private gist from region or buffer
 | 
					  "Prompt for confirmation before permitting a push to upstream."
 | 
				
			||||||
 | 
					  (when-let ((branch (magit-get-current-branch)))
 | 
				
			||||||
 | 
					    (unless (yes-or-no-p (format "Push %s branch upstream to %s? "
 | 
				
			||||||
 | 
					                                 branch
 | 
				
			||||||
 | 
					                                 (or (magit-get-upstream-branch branch)
 | 
				
			||||||
 | 
					                                     (magit-get "branch" branch "remote"))))
 | 
				
			||||||
 | 
					      (user-error "Push to upstream aborted by user"))))
 | 
				
			||||||
#+END_SRC
 | 
					#+END_SRC
 | 
				
			||||||
** Web Browsing
 | 
					** Web Browsing
 | 
				
			||||||
*** EWW
 | 
					*** EWW
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue