Skip to content
Open
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
49998e0
refactor: rename `new_github_repository_name` to `repository_name` in…
paulo-granthon May 11, 2024
b87eeae
refactor!: rename `CreateGitHubCurl` function to `Create` in `core.repo`
paulo-granthon May 11, 2024
e90794c
refactor!: rename `InitGitHub` function to `Init` in `core.repo`
paulo-granthon May 11, 2024
fad59f1
chore: remove trailing `/` in return value of `build_github_html_url`…
paulo-granthon Jun 12, 2024
7e7f5d4
fix(error): stop `throw` recursing until the stack overflows
paulo-granthon Aug 25, 2026
e05d1a8
fix(core.repo): report missing credentials instead of crashing
paulo-granthon Aug 25, 2026
0494eac
fix(core.repo): stop `Create` continuing after a failed request
paulo-granthon Aug 25, 2026
7587461
fix(service.github): send valid JSON when creating a repository
paulo-granthon Aug 25, 2026
c055f49
fix(parse_args): return the unmatched arguments as the documented sec…
paulo-granthon Aug 25, 2026
a47040a
fix(util): honour the documented return pair and unshadow `table`
paulo-granthon Aug 25, 2026
5368440
fix(core.repo): restore the space before the remote URL in `Init`
paulo-granthon Aug 25, 2026
bf2e36c
refactor!: report through `vim.notify` instead of `nvim_err_writeln`
paulo-granthon Aug 25, 2026
3de4d7b
docs: record why the Projects functions are blocked
paulo-granthon Aug 25, 2026
cf68708
chore: let specs stub `vim` fields without tripping luacheck
paulo-granthon Aug 25, 2026
6af8f29
Merge branch 'ci-setup' into fixes-general
paulo-granthon Aug 25, 2026
3356173
fix: make module load guards actually stop the load
paulo-granthon Aug 25, 2026
7a1fc91
Merge branch 'ci-setup' into fixes-general
paulo-granthon Aug 26, 2026
ba7dcdd
fix(service.github): build curl calls as argv instead of a shell string
paulo-granthon Aug 26, 2026
d47c29e
fix(service.github): stop a malformed response from crashing the command
paulo-granthon Aug 26, 2026
31b8b32
fix(service.github): include the decode failure in the error
paulo-granthon Aug 26, 2026
405542c
Merge branch 'ci-setup' into fixes-general
paulo-granthon Aug 26, 2026
624d613
fix: stop misclassifying org lookup failures, and drop the last shell…
paulo-granthon Aug 26, 2026
f42884d
fix(service.github): capture curl's error output
paulo-granthon Aug 26, 2026
ae4d4c3
Merge branch 'ci-setup' into fixes-general
paulo-granthon Aug 26, 2026
4b03779
fix: stop double reporting, validate `-v`, and correct the throw docs…
paulo-granthon Aug 26, 2026
a9655ad
fix(core.repo): report GitHub's message when there is no errors array
paulo-granthon Aug 26, 2026
33ca549
feat(util): add one git runner that resolves the buffer's repository
paulo-granthon Aug 26, 2026
d3911e0
feat(util): let `git` take an explicit directory
paulo-granthon Aug 26, 2026
b6b1572
test(util): cover the git runner and buffer resolution
paulo-granthon Aug 26, 2026
cf39deb
Merge branch 'ci-setup' into fixes-general
paulo-granthon Aug 26, 2026
88eb264
Merge branch 'ci-setup' into fixes-general
paulo-granthon Aug 26, 2026
cade8c3
fix(util): report the Neovim requirement instead of crashing on it
paulo-granthon Aug 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ exclude_files = {

files['tests/'] = {
std = '+busted',
-- Specs stub `vim` fields such as `vim.notify` to capture output,
-- so the table is writable here even though plugin code may only read it.
globals = { 'vim' },
}
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Every agitate command starts with `:Agitate` and is followed by the
context and the action. Example:

```vim
:AgitateRepoCreateGitHub
:AgitateRepoCreate
```

### Available contexts
Expand All @@ -25,11 +25,11 @@ You can easily verify what the commands are and what they do by looking at the

#### Repo

- `:AgitateRepoCreateGitHub` - Create a new remote repository on GitHub.
- `:AgitateRepoCreate` - Create a new remote repository on GitHub.
Uses the repository name provided as an optional argument **_or_** the current
directory as the repository name if no argument is provided.

- `:AgitateRepoInitGitHub` - Initializes the current directory as a GitHub
- `:AgitateRepoInit` - Initializes the current directory as a GitHub
repository.
Uses the repository name provided as an optional argument **_or_** the current
directory as the repository name if no argument is provided.
Expand All @@ -50,16 +50,16 @@ to bind them to a keybinding to be able to use `Agitate` with less friction.
vimscript:

```vim
nnoremap <leader>gil :AgitateRepoInitGitHub
nnoremap <leader>gir :AgitateRepoCreateGitHub
nnoremap <leader>gil :AgitateRepoInit
nnoremap <leader>gir :AgitateRepoCreate
nnoremap <leader>gbp :AgitateBranchCreateCheckoutAndPush
```

lua:

```lua
vim.keymap.set('n', '<leader>gil', ':AgitateRepoInitGitHub ')
vim.keymap.set('n', '<leader>gir', ':AgitateRepoCreateGitHub ')
vim.keymap.set('n', '<leader>gil', ':AgitateRepoInit ')
vim.keymap.set('n', '<leader>gir', ':AgitateRepoCreate ')
vim.keymap.set('n', '<leader>gbp', ':AgitateBranchCreateCheckoutAndPush ')
```

Expand Down Expand Up @@ -146,7 +146,10 @@ Features planned for implementation
- todo!()

- [ ] Project functions:
- todo!()
- Blocked. The classic Projects REST API has been sunset and Projects V2 is
reachable only through GraphQL, so this needs a GraphQL client alongside
the REST one and a token carrying the `project` scope. Worth revisiting
once the REST backed features have landed.

## Contributing

Expand Down
8 changes: 5 additions & 3 deletions lua/agitate/api/branch.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
local M = {}

local ok, error = pcall(require, 'agitate.error')
local ok, agitate_error = pcall(require, 'agitate.error')
if not ok then
return vim.api.nvim_err_writeln(require('agitate.const.error').import)
local message = require('agitate.const.error').import
vim.notify(message, vim.log.levels.ERROR)
error(message, 0)
end
Comment on lines +3 to 8

function M.setup()
vim.api.nvim_create_user_command('AgitateBranchCreateCheckoutAndPush', function(opts)
local branch_ok, branch_or_err = pcall(require, 'agitate.core.branch')
if not branch_ok then
return error.throw(branch_or_err)
return agitate_error.throw(branch_or_err)
end

branch_or_err.CreateCheckoutAndPush(opts.fargs[1])
Expand Down
10 changes: 6 additions & 4 deletions lua/agitate/api/init.lua
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
local M = {}

local ok, error = pcall(require, 'agitate.error')
local ok, agitate_error = pcall(require, 'agitate.error')
if not ok then
return vim.api.nvim_err_writeln(require('agitate.const.error').import)
local message = require('agitate.const.error').import
vim.notify(message, vim.log.levels.ERROR)
error(message, 0)
end
Comment on lines +3 to 8

function M.setup()
local branch_ok, branch_or_err = pcall(require, 'agitate.api.branch')
if branch_ok then
branch_or_err.setup()
else
error.throw(branch_or_err)
agitate_error.throw(branch_or_err)
end

local repo_ok, repo_or_err = pcall(require, 'agitate.api.repo')
if repo_ok then
repo_or_err.setup()
else
error.throw(repo_or_err)
agitate_error.throw(repo_or_err)
end
end

Expand Down
18 changes: 10 additions & 8 deletions lua/agitate/api/repo.lua
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
local M = {}

local ok, error = pcall(require, 'agitate.error')
local ok, agitate_error = pcall(require, 'agitate.error')
if not ok then
return vim.api.nvim_err_writeln(require('agitate.const.error').import)
local message = require('agitate.const.error').import
vim.notify(message, vim.log.levels.ERROR)
error(message, 0)
end
Comment on lines +3 to 8

function M.setup()
vim.api.nvim_create_user_command('AgitateRepoCreateGitHub', function(opts)
vim.api.nvim_create_user_command('AgitateRepoCreate', function(opts)
local repo_ok, repo_or_err = pcall(require, 'agitate.core.repo')
if not repo_ok then
return error.throw(repo_or_err)
return agitate_error.throw(repo_or_err)
end

repo_or_err.CreateGitHubCurl(opts.fargs)
repo_or_err.Create(opts.fargs)
end, {
nargs = '*',
desc = "Creates a new repository at 'github.com/<github_username>/<argument or current_directory>/'",
})

vim.api.nvim_create_user_command('AgitateRepoInitGitHub', function(opts)
vim.api.nvim_create_user_command('AgitateRepoInit', function(opts)
local repo_ok, repo_or_err = pcall(require, 'agitate.core.repo')
if not repo_ok then
return error.throw(repo_or_err)
return agitate_error.throw(repo_or_err)
end

repo_or_err.InitGitHub(opts.fargs)
repo_or_err.Init(opts.fargs)
end, {
nargs = '*',
desc = "Initialize the current directory as a repository at 'github.com/<github_username>/<argument or current_directory>/'",
Expand Down
15 changes: 11 additions & 4 deletions lua/agitate/config.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
local M = {}

local ok, error = pcall(require, 'agitate.error')
local ok, agitate_error = pcall(require, 'agitate.error')
if not ok then
return vim.api.nvim_err_writeln(require('agitate.const.error').import)
local message = require('agitate.const.error').import
vim.notify(message, vim.log.levels.ERROR)
error(message, 0)
end

local types_ok, types_or_err = pcall(require, 'agitate.types.config')
if not types_ok then
return error.throw(types_or_err)
agitate_error.throw(types_or_err)
error(types_or_err, 0)
end
Comment on lines +3 to 14

---@type Config
Expand All @@ -33,7 +36,11 @@ function M.setup(options)
if api_ok then
api_or_err.setup()
else
error.throw(api_or_err)
-- Raised rather than reported and shrugged off. Without the api module no
-- commands exist, so continuing leaves the plugin loaded and inert, which
-- is harder to diagnose than a failed setup.
agitate_error.throw(api_or_err)
error(api_or_err, 0)
end
Comment on lines 35 to 44
end

Expand Down
2 changes: 1 addition & 1 deletion lua/agitate/core/branch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function M.CreateCheckoutAndPush(branch_name)
vim.cmd('G checkout -b ' .. branch_name)
vim.cmd('G push -u origin ' .. branch_name)
else
print('Please provide an argument for the name of the branch')
vim.notify('core.branch.CreateCheckoutAndPush -- Error: no branch name provided', vim.log.levels.ERROR)
end
end

Expand Down
Loading
Loading