Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pwntester/octo.nvim
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvaro Muñoz committed Jan 26, 2023
2 parents 0c02318 + 52b2c97 commit 66e8ea2
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ require"octo".setup({
left_bubble_delimiter = ""; -- bubble delimiter
github_hostname = ""; -- GitHub Enterprise host
snippet_context_lines = 4; -- number or lines around commented lines
gh_env = {}, -- extra environment variables to pass on to GitHub CLI, can be a table or function returning a table
issues = {
order_by = { -- criteria to sort results of `Octo issue list`
field = "CREATED_AT", -- either COMMENTS, CREATED_AT or UPDATED_AT (https://docs.github.com/en/graphql/reference/enums#issueorderfield)
Expand Down Expand Up @@ -268,6 +269,7 @@ If no command is passed, the argument to `Octo` is treated as a URL from where a
| | fork | Fork repo |
| | browser | Open current repo in the browser|
| | url | Copies the URL of the current repo to the system clipboard|
| | view | Open a repo by path ({organization}/{name})|
| gist | list [repo] [key=value] (4) | List user gists |
| comment | add | Add a new comment |
| | delete | Delete a comment |
Expand All @@ -276,7 +278,7 @@ If no command is passed, the argument to `Octo` is treated as a URL from where a
| label | add [label] | Add a label from available label menu |
| | remove [label] | Remove a label |
| | create [label] | Create a new label |
| assignees| add [login] | Assign a user |
| assignee| add [login] | Assign a user |
| | remove [login] | Unassign a user |
| reviewer | add [login] | Assign a PR reviewer |
| reaction | `thumbs_up` \| `+1` | Add 👍 reaction|
Expand All @@ -296,6 +298,7 @@ If no command is passed, the argument to `Octo` is treated as a URL from where a
| | discard| Deletes a pending review for current PR if any |
| | comments| View pending review comments |
| | commit | Pick a specific commit to review |
| | close | Close the review window and return to the PR |
| actions | | Lists all available Octo actions|
| search | <query> | Search GitHub for issues and PRs matching the [query](https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests) |

Expand Down
6 changes: 4 additions & 2 deletions doc/octo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ See |octo-command-examples| for examples.

list Lists repos the user owns, contributes, or belongs to.
fork Fork repo.
browser Open current PR in the browser.
browser Open current repo in the browser.
url Copies the URL of the current repo to the system
clipboard.
view Open a repo by path ({organization}/{name}).


:Octo gist [action] *octo-commands-gist*
Expand Down Expand Up @@ -114,7 +115,7 @@ See |octo-command-examples| for examples.
create [label] Create a new label.


:Octo assignees [action] *octo-commands-assignees*
:Octo assignee [action] *octo-commands-assignee*

add [login] Assign a user.
remove [login] Unassign a user
Expand Down Expand Up @@ -152,6 +153,7 @@ See |octo-command-examples| for examples.
discard Deletes a pending review for the current PR, if any.
comments View pending review comments.
commit Pick a specific commit to review.
close Close the review window and return to the PR.

:Octo actions *octo-commands-actions*

Expand Down
3 changes: 3 additions & 0 deletions lua/octo/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ function M.setup()
rocket = function()
M.reaction_action "ROCKET"
end,
heart = function()
M.reaction_action "HEART"
end,
},
card = {
add = function()
Expand Down
1 change: 1 addition & 0 deletions lua/octo/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ M.defaults = {
left_bubble_delimiter = "",
github_hostname = "",
snippet_context_lines = 4,
gh_env = {},
issues = {
order_by = {
field = "CREATED_AT",
Expand Down
19 changes: 17 additions & 2 deletions lua/octo/gh/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,28 @@ local env_vars = {
https_proxy = vim.env["https_proxy"],
}

local function get_env()
local env = env_vars
local gh_env = config.get_config().gh_env
if type(gh_env) == "function" then
local computed_env = gh_env()
if type(computed_env) == "table" then
env = vim.tbl_deep_extend("force", env, computed_env)
end
elseif type(gh_env) == "table" then
env = vim.tbl_deep_extend("force", env, gh_env)
end

return env
end

-- uses GH to get the name of the authenticated user
function M.get_user_name()
local job = Job:new {
enable_recording = true,
command = "gh",
args = { "auth", "status" },
env = env_vars,
env = get_env(),
}
job:sync()
local stderr = table.concat(job:stderr_result(), "\n")
Expand Down Expand Up @@ -90,7 +105,7 @@ function M.run(opts)
opts.cb(output, stderr)
end
end),
env = env_vars,
env = get_env(),
}
if mode == "sync" then
job:sync()
Expand Down
3 changes: 3 additions & 0 deletions lua/octo/ui/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ function M.create_centered_float(opts)
else
opts.height = math.min(vim_height, 2 * opts.border_width + #opts.content) + 1
end

opts.width = math.floor(opts.width)
opts.height = math.floor(opts.height)
else
opts.width = math.floor(vim_width * opts.x_percent)
opts.height = math.floor(vim_height * opts.y_percent)
Expand Down

0 comments on commit 66e8ea2

Please sign in to comment.