Skip to content

Commit 7af24df

Browse files
committed
feat(git): support pushing a single tag by name
- add tag_name parameter to push command in documentation and schema - update GitTool.push to handle tag_name argument - modify git_edit to pass tag_name to GitTool.push
1 parent 759c4f6 commit 7af24df

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ In any CodeCompanion chat buffer, use `@git_read` or `@git_edit` to perform Git
156156
- `@git_edit gitignore_add --gitignore_rule "RULE"` - Add rule to .gitignore
157157
- `@git_edit gitignore_add --gitignore_rules ["rule1", "rule2"]` - Add multiple rules
158158
`@git_edit gitignore_remove --gitignore_rule "RULE"` - Remove rule from .gitignore
159-
`@git_edit push [--remote REMOTE] [--branch BRANCH] [--force BOOL] [--tags BOOL]` - Push changes to a remote repository.
159+
`@git_edit push [--remote REMOTE] [--branch BRANCH] [--force BOOL] [--tags BOOL] [--tag_name NAME]` - Push changes to a remote repository.
160160
WARNING: `force` push is dangerous and can overwrite remote history. Use with extreme caution.
161161
`@git_edit rebase [--onto ONTO] [--base BASE] [--interactive BOOL]` - Rebase current branch onto another.
162162
WARNING: `interactive` rebase opens an editor and is not suitable for automated environments. It can also rewrite history.

doc/codecompanion-gitcommit.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ GitIgnore Management~
425425
• `@git_edit rebase: Rebase current branch (WARNING: interactive rebase is dangerous)
426426
• `@git_edit cherry_pick: Apply changes from existing commits
427427
• `@git_edit revert: Revert a commit
428-
• `@git_edit push [--remote REMOTE] [--branch BRANCH] [--force BOOL] [--tags BOOL]` - Push changes to a remote repository.
428+
• `@git_edit push [--remote REMOTE] [--branch BRANCH] [--force BOOL] [--tags BOOL] [--tag_name NAME]` - Push changes to a remote repository.
429429
WARNING: `force` push is dangerous and can overwrite remote history. Use with extreme caution.
430430

431431
7.4 Safety Features *codecompanion-gitcommit-safety*

lua/codecompanion/_extensions/gitcommit/tools/git.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,9 @@ end
394394
---@param branch? string The name of the branch to push (defaults to current branch)
395395
---@param force? boolean Force push (DANGEROUS: overwrites remote history)
396396
---@param tags? boolean Push all tags
397+
---@param tag_name? string The name of a single tag to push
397398
---@return boolean success, string output
398-
function GitTool.push(remote, branch, force, tags)
399+
function GitTool.push(remote, branch, force, tags, tag_name)
399400
local cmd = "git push"
400401
if force then
401402
cmd = cmd .. " --force"
@@ -409,6 +410,9 @@ function GitTool.push(remote, branch, force, tags)
409410
if tags then
410411
cmd = cmd .. " --tags"
411412
end
413+
if tag_name then
414+
cmd = cmd .. " " .. vim.fn.shellescape(tag_name)
415+
end
412416
return execute_git_command(cmd)
413417
end
414418

lua/codecompanion/_extensions/gitcommit/tools/git_edit.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ GitEdit.schema = {
102102
type = "boolean",
103103
description = "Push all tags",
104104
},
105+
tag_name = {
106+
type = "string",
107+
description = "The name of a single tag to push",
108+
},
105109
onto = {
106110
type = "string",
107111
description = "The branch to rebase onto",
@@ -241,7 +245,7 @@ Available write-access Git operations:
241245
end
242246
success, output = GitTool.remove_gitignore_rule(rules)
243247
elseif operation == "push" then
244-
success, output = GitTool.push(op_args.remote, op_args.branch, op_args.force, op_args.tags)
248+
success, output = GitTool.push(op_args.remote, op_args.branch, op_args.force, op_args.tags, op_args.tag_name)
245249
elseif operation == "rebase" then
246250
success, output = GitTool.rebase(op_args.onto, op_args.base, op_args.interactive)
247251
elseif operation == "cherry_pick" then

0 commit comments

Comments
 (0)