From f0a577fb907776756cee09561526bb9bec32b30b Mon Sep 17 00:00:00 2001 From: Mat Jones Date: Fri, 9 Dec 2022 10:09:57 -0500 Subject: [PATCH 1/6] add ability to set computed env vars for gh cli --- lua/octo/config.lua | 1 + lua/octo/gh/init.lua | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lua/octo/config.lua b/lua/octo/config.lua index 645c9887..55fb93fb 100644 --- a/lua/octo/config.lua +++ b/lua/octo/config.lua @@ -15,6 +15,7 @@ M.defaults = { left_bubble_delimiter = "", github_hostname = "", snippet_context_lines = 4, + get_env = nil, issues = { order_by = { field = "CREATED_AT", diff --git a/lua/octo/gh/init.lua b/lua/octo/gh/init.lua index c1091f6c..d49fb21b 100644 --- a/lua/octo/gh/init.lua +++ b/lua/octo/gh/init.lua @@ -25,13 +25,25 @@ local env_vars = { https_proxy = vim.env["https_proxy"], } +local function get_env() + local env = env_vars + if type(config.get_config().get_env) == 'function' then + local computed_env = config.get_config().get_env() + if type(computed_env) == 'table' then + env = vim.tbl_deep_extend('force', env, computed_env) + end + 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") @@ -90,7 +102,7 @@ function M.run(opts) opts.cb(output, stderr) end end), - env = env_vars, + env = get_env(), } if mode == "sync" then job:sync() From 96dedd473d33f8a23f151b70683f6c0cd41ea610 Mon Sep 17 00:00:00 2001 From: yen3 Date: Mon, 12 Dec 2022 20:45:00 +0100 Subject: [PATCH 2/6] Fix the floating window size calculation If the number of max lines >= 1, it calculates a float number. It could apply to `vim.api.nvim_open_win`. Add the converting action to make sure the final result type is int. --- lua/octo/ui/window.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/octo/ui/window.lua b/lua/octo/ui/window.lua index 07fdf1a9..f11a3b21 100644 --- a/lua/octo/ui/window.lua +++ b/lua/octo/ui/window.lua @@ -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) From 2cdd792d109d0990b51703fac9b81611750c5709 Mon Sep 17 00:00:00 2001 From: Mat Jones Date: Tue, 13 Dec 2022 07:30:57 -0500 Subject: [PATCH 3/6] rename option and support table value --- README.md | 1 + lua/octo/config.lua | 2 +- lua/octo/gh/init.lua | 11 +++++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 930f4588..a5edee7a 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/lua/octo/config.lua b/lua/octo/config.lua index 55fb93fb..b37ad499 100644 --- a/lua/octo/config.lua +++ b/lua/octo/config.lua @@ -15,7 +15,7 @@ M.defaults = { left_bubble_delimiter = "", github_hostname = "", snippet_context_lines = 4, - get_env = nil, + gh_env = {}, issues = { order_by = { field = "CREATED_AT", diff --git a/lua/octo/gh/init.lua b/lua/octo/gh/init.lua index d49fb21b..d483d57e 100644 --- a/lua/octo/gh/init.lua +++ b/lua/octo/gh/init.lua @@ -27,11 +27,14 @@ local env_vars = { local function get_env() local env = env_vars - if type(config.get_config().get_env) == 'function' then - local computed_env = config.get_config().get_env() - if type(computed_env) == 'table' then - env = vim.tbl_deep_extend('force', env, computed_env) + 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 From a29fb24dc79daebf67069701074e8553388760c7 Mon Sep 17 00:00:00 2001 From: Oscar Caballero Date: Tue, 17 Jan 2023 12:57:39 +0100 Subject: [PATCH 4/6] Add missing heart reaction command --- lua/octo/commands.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/octo/commands.lua b/lua/octo/commands.lua index 55b0a123..bc93c1cc 100644 --- a/lua/octo/commands.lua +++ b/lua/octo/commands.lua @@ -271,6 +271,9 @@ function M.setup() rocket = function() M.reaction_action "ROCKET" end, + heart = function() + M.reaction_action "HEART" + end, }, card = { add = function() From ec1e0e891457eaed10f27b92109abca5e1d47811 Mon Sep 17 00:00:00 2001 From: Oscar Caballero Date: Tue, 17 Jan 2023 13:00:18 +0100 Subject: [PATCH 5/6] Fix small typos in docs --- doc/octo.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/octo.txt b/doc/octo.txt index 403e4c99..b39c5fbd 100644 --- a/doc/octo.txt +++ b/doc/octo.txt @@ -82,7 +82,7 @@ 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. @@ -114,7 +114,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 From 3dc1286eef7eb14f42831950fc7d290c67199627 Mon Sep 17 00:00:00 2001 From: Oscar Caballero Date: Tue, 17 Jan 2023 13:00:51 +0100 Subject: [PATCH 6/6] Add missing repo-view and review-close docs --- README.md | 4 +++- doc/octo.txt | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a5edee7a..7f602aaa 100644 --- a/README.md +++ b/README.md @@ -269,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 | @@ -277,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| @@ -297,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 | | Search GitHub for issues and PRs matching the [query](https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests) | diff --git a/doc/octo.txt b/doc/octo.txt index b39c5fbd..e22ff5c3 100644 --- a/doc/octo.txt +++ b/doc/octo.txt @@ -85,6 +85,7 @@ See |octo-command-examples| for examples. 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* @@ -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*