Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github: Add forge #11764

Closed
wants to merge 1 commit into from
Closed

github: Add forge #11764

wants to merge 1 commit into from

Conversation

Miciah
Copy link
Contributor

@Miciah Miciah commented Dec 28, 2018

Note that Forge binds the ' key to the Forge dispatch popup, but evil-magit binds the ' key to the submodule dispatch popup (see emacs-evil/evil-magit#54), and evil-magit's key binding takes precedence with the vim editing style. Because Forge's key binding does not always work, it is omitted from the README.

Note also that Magit binds the % key to its worktree dispatch popup, but Spacemacs binds the % key to the magit-gitflow popup, and Spacemacs's key binding takes precedence. Because there is no available key binding for the worktree dispatch popup, Forge's key binding under that dispatch popup is omitted from the README.

  • layers/+source-control/github/README.org: Update.
  • layers/+source-control/github/packages.el (github-packages): Add forge.
    (github/init-forge): Load forge after magit. Configure forge to use spacemacs-cache-directory.
    (github/init-magithub): Disabling injecting issues and pull-requests sections if forge is installed.

@nixmaniack
Copy link
Contributor

Shouldn't forge and magithub be mutually exclusive?

@nixmaniack
Copy link
Contributor

Also, since forge isn't just github specific it might make more sense to include it in git layer alongside magit.

@yuhan0
Copy link
Contributor

yuhan0 commented Dec 29, 2018

I don't think they're entirely exclusive (see the comments here) but having both installed does seem redundant from spacemacs perspective.

Maybe move both the forge and magithub packages over to the git layer and introduce a "backend" config variable? Something like

(defvar git-forge-backend 'forge
  "The backend to use for Magit integration with external Git forges like Github.
Possible values are `forge' and `magithub'. Leave nil to disable forge support.")

with the corresponding :toggles in the package list.

Not 100% sure but I believe the magit-gh-pulls package is also superseded by forge.

@Miciah
Copy link
Contributor Author

Miciah commented Dec 29, 2018

Shouldn't forge and magithub be mutually exclusive?

They do not completely overlap in functionality. For example, Magithub reports CI status, and Forge supports reading issues and posting and editing comments. The authors of the respective packages appear to be interested in the packages merging or morphing into complementary roles (see this reddit discussion involving the authors of Magithub and Forge).

Also, since forge isn't just github specific it might make more sense to include it in git layer alongside magit.

Fair point. Counterpoint: The github layer could be renamed to forge.

Maybe move both the forge and magithub packages over to the git layer and introduce a "backend" config variable?

I can do this, but Magithub's future is uncertain, and it appears that Magithub will likely change to fit a complementary role to Forge, or that they will somehow "come to a single solution" (see the above link to the related reddit discussion).

Not 100% sure but I believe the magit-gh-pulls package is also superseded by forge.

@robbyoconnor made #10684 to remove magit-gh-pulls, but
@sdwolfz closed it because Magithub was not a satisfactory replacement. @sdwolfz will have to comment whether Forge is a satisfactory replacement for magit-gh-pulls.

Copy link
Contributor

@robbyoconnor robbyoconnor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't test but looks good to me :)

@Miciah
Copy link
Contributor Author

Miciah commented Dec 30, 2018

Latest push configures Magithub not to inject issues and pull-requests sections if forge is installed.

Note that Forge binds the ' key to the Forge dispatch popup, but evil-magit
binds the ' key to the submodule dispatch popup (see
emacs-evil/evil-magit#54), and evil-magit's key
binding takes precedence with the vim editing style.  Because Forge's key
binding does not always work, it is omitted from the README.

Note also that Magit binds the % key to its worktree dispatch popup, but
Spacemacs binds the % key to the magit-gitflow popup, and Spacemacs's key
binding takes precedence.  Because there is no available key binding for
the worktree dispatch popup, Forge's key binding under that dispatch popup
is omitted from the README.

* CHANGELOG.develop:
* layers/+source-control/github/README.org: Update.
* layers/+source-control/github/packages.el (github-packages): Add forge.
(github/init-forge): Load forge after magit. Configure forge to use
spacemacs-cache-directory.
(github/init-magithub): Disabling injecting issues and pull-requests
sections if forge is installed.
@Miciah
Copy link
Contributor Author

Miciah commented Dec 30, 2018

Pushed a small formatting fixup.

@sdwolfz sdwolfz added this to the Release 0.300 milestone Dec 30, 2018
@yuhan0
Copy link
Contributor

yuhan0 commented Jan 1, 2019

The commands to create pull requests and issues cannot be accessed except through the Forge popup key ', perhaps this PR should wait for emacs-evil/evil-magit#54 to be resolved or decide on a Spacemacs specific binding?

@yuhan0
Copy link
Contributor

yuhan0 commented Jan 1, 2019

This can also be included in the :init section to set up the ",c" / ",k" conventions

(spacemacs/set-leader-keys-for-major-mode 'forge-post-mode
  dotspacemacs-major-mode-leader-key 'forge-post-submit
  "c" 'forge-post-submit
  "k" 'forge-post-cancel
  "a" 'forge-post-cancel)

@dcluna
Copy link
Contributor

dcluna commented Jan 3, 2019

Nice work, @Miciah ! I didn't know about forge but this seems like a nice addition.

I haven't tested this branch yet, but the PR seems good to me. I'm personally in favor of removing Magithub / magit-gh-pulls if Forge works as a replacement for both (as it seems to do).

@sdwolfz
Copy link
Contributor

sdwolfz commented Jan 14, 2019

Are you able to check out PRs, or forge-pull? because it gives me:

Debugger entered--Lisp error: (error "BUG: missing headers nil")
  signal(error ("BUG: missing headers nil"))
  error("BUG: missing headers %s" nil)
  ghub--handle-response-headers(nil #s(ghub--req :url #s(url :type "https" :user nil :password nil :host "api.github.com" :portspec nil :filename "/graphql" :target nil :attributes nil :fullness t :silent nil :use-cookies t :asynchronous nil) :forge nil :silent nil :method "POST" :headers #f(compiled-function () #<bytecode 0x232f629>) :handler ghub--handle-response :unpaginate nil :noerror nil :reader nil :callback nil :errorback nil :value nil :extra nil))
  ghub--handle-response(nil #s(ghub--req :url #s(url :type "https" :user nil :password nil :host "api.github.com" :portspec nil :filename "/graphql" :target nil :attributes nil :fullness t :silent nil :use-cookies t :asynchronous nil) :forge nil :silent nil :method "POST" :headers #f(compiled-function () #<bytecode 0x232f629>) :handler ghub--handle-response :unpaginate nil :noerror nil :reader nil :callback nil :errorback nil :value nil :extra nil))
  ghub--retrieve("{\"query\":\"query ($owner:String!, $name:String!) {\\..." #s(ghub--req :url #s(url :type "https" :user nil :password nil :host "api.github.com" :portspec nil :filename "/graphql" :target nil :attributes nil :fullness t :silent nil :use-cookies t :asynchronous nil) :forge nil :silent nil :method "POST" :headers #f(compiled-function () #<bytecode 0x232f629>) :handler ghub--handle-response :unpaginate nil :noerror nil :reader nil :callback nil :errorback nil :value nil :extra nil))
  ghub-request("POST" "/graphql" nil :payload "{\"query\":\"query ($owner:String!, $name:String!) {\\..." :silent nil :username nil :auth forge :host "api.github.com" :callback nil :errorback nil :extra nil :value nil)
  ghub-graphql("query ($owner:String!, $name:String!) {\n          ..." ((owner . "syl20bnr") (name . "spacemacs")) :username nil :auth forge :host "api.github.com")
  ghub--repository-id("syl20bnr" "spacemacs" :username nil :auth forge :host "api.github.com")
  ghub-repository-id("syl20bnr" "spacemacs" :host "api.github.com" :auth forge :forge ghub)
  #f(compiled-function (class host owner name &optional stub) "Return (OUR-ID . THEIR-ID) of the specified repository.\nIf optional STUB is non-nil, then the IDs are not guaranteed to\nbe unique.  Otherwise this method has to make an API request to\nretrieve THEIR-ID, the repository's ID on the forge.  In that\ncase OUR-ID derives from THEIR-ID and is unique across all\nforges and hosts.  " #<bytecode 0x216ba19>)(forge-github-repository "github.com" "syl20bnr" "spacemacs" nil)
  apply(#f(compiled-function (class host owner name &optional stub) "Return (OUR-ID . THEIR-ID) of the specified repository.\nIf optional STUB is non-nil, then the IDs are not guaranteed to\nbe unique.  Otherwise this method has to make an API request to\nretrieve THEIR-ID, the repository's ID on the forge.  In that\ncase OUR-ID derives from THEIR-ID and is unique across all\nforges and hosts.  " #<bytecode 0x216ba19>) forge-github-repository ("github.com" "syl20bnr" "spacemacs" nil))
  forge--repository-ids(forge-github-repository "github.com" "syl20bnr" "spacemacs" nil)
  #f(compiled-function (&rest rest) "Return the repository identified by HOST, OWNER and NAME." #<bytecode 0x216c5ad>)(("github.com" "syl20bnr" "spacemacs") "origin" create)
  apply(#f(compiled-function (&rest rest) "Return the repository identified by HOST, OWNER and NAME." #<bytecode 0x216c5ad>) ("github.com" "syl20bnr" "spacemacs") ("origin" create))
  forge-get-repository(("github.com" "syl20bnr" "spacemacs") "origin" create)
  #f(compiled-function (url &optional remote demand) "Return the repository at URL." #<bytecode 0x216c541>)("[email protected]:syl20bnr/spacemacs.git" "origin" create)
  apply(#f(compiled-function (url &optional remote demand) "Return the repository at URL." #<bytecode 0x216c541>) "[email protected]:syl20bnr/spacemacs.git" ("origin" create))
  forge-get-repository("[email protected]:syl20bnr/spacemacs.git" "origin" create)
  #f(compiled-function (demand &optional remote) "Return the forge repository for the current Git repository." #<bytecode 0x216c529>)(create)
  apply(#f(compiled-function (demand &optional remote) "Return the forge repository for the current Git repository." #<bytecode 0x216c529>) create nil)
  forge-get-repository(create)
  forge-pull()
  funcall-interactively(forge-pull)
  call-interactively(forge-pull record nil)
  command-execute(forge-pull record)
  helm-M-x(nil #("forge-pull" 0 10 (match-part "forge-pull")))
  funcall-interactively(helm-M-x nil #("forge-pull" 0 10 (match-part "forge-pull")))
  call-interactively(helm-M-x nil nil)
  command-execute(helm-M-x)

And I am not sure if it's because of something I have....

@sdwolfz
Copy link
Contributor

sdwolfz commented Jan 14, 2019

Thank you ❤️!

Hopefully that issue will be fixed upstream, merging right now as the PR checkout functionality is missing from magithub, and gh-pull-requests is unusable.

Cherry-picked into develop branch, you can safely delete your branch.
Commit: 07aa9b0

@sdwolfz sdwolfz closed this Jan 14, 2019
@Miciah
Copy link
Contributor Author

Miciah commented Jan 17, 2019

Are you able to check out PRs, or forge-pull? because it gives me:

As of today, yes. I am able to do a forge-pull on the Spacemacs repository and see the latest issues and pull requests. Are you using the latest forge, ghub, and graphql packages? Looks like you may have encountered a problem in one of those packages.

@sdwolfz
Copy link
Contributor

sdwolfz commented Jan 20, 2019

Starting with today's update forge is working for me as well 🎉.

It's still slower than the previous approaches but I have faith it will get better in the future. Anyway I'll update the Collaborator PR Guide to mention forge now and will add a note about the wget + git am fallback in case something breaks.

@yssource
Copy link
Contributor

Debugger entered--Lisp error: (error "BUG: missing headers nil")

The upstream bug bothers me very much. And it seems to be related with magit/ghub#81

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants