Add --force option to crewai tool publish (#1383)

This commit adds an option to bypass Git remote validations when
publishing tools.
This commit is contained in:
Vini Brasil
2024-10-04 11:02:50 -03:00
committed by GitHub
parent d063ed3014
commit 5dee13e078
3 changed files with 316 additions and 271 deletions

View File

@@ -276,12 +276,13 @@ def tool_install(handle: str):
@tool.command(name="publish")
@click.option("--force", is_flag=True, show_default=True, default=False, help="Bypasses Git remote validations")
@click.option("--public", "is_public", flag_value=True, default=False)
@click.option("--private", "is_public", flag_value=False)
def tool_publish(is_public: bool):
def tool_publish(is_public: bool, force: bool):
tool_cmd = ToolCommand()
tool_cmd.login()
tool_cmd.publish(is_public)
tool_cmd.publish(is_public, force)
@crewai.group()

View File

@@ -59,8 +59,8 @@ class ToolCommand(BaseCommand, PlusAPIMixin):
finally:
os.chdir(old_directory)
def publish(self, is_public: bool):
if not git.Repository().is_synced():
def publish(self, is_public: bool, force: bool = False):
if not git.Repository().is_synced() and not force:
console.print(
"[bold red]Failed to publish tool.[/bold red]\n"
"Local changes need to be resolved before publishing. Please do the following:\n"