mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
Add Git validations for publishing tools (#1381)
This commit prevents tools from being published if the underlying Git repository is unsynced with origin.
This commit is contained in:
@@ -6,6 +6,7 @@ import subprocess
|
||||
import tempfile
|
||||
|
||||
from crewai.cli.command import BaseCommand, PlusAPIMixin
|
||||
from crewai.cli import git
|
||||
from crewai.cli.utils import (
|
||||
get_project_name,
|
||||
get_project_description,
|
||||
@@ -59,6 +60,17 @@ class ToolCommand(BaseCommand, PlusAPIMixin):
|
||||
os.chdir(old_directory)
|
||||
|
||||
def publish(self, is_public: bool):
|
||||
if not git.Repository().is_synced():
|
||||
console.print(
|
||||
"[bold red]Failed to publish tool.[/bold red]\n"
|
||||
"Local changes need to be resolved before publishing. Please do the following:\n"
|
||||
"* [bold]Commit[/bold] your changes.\n"
|
||||
"* [bold]Push[/bold] to sync with the remote.\n"
|
||||
"* [bold]Pull[/bold] the latest changes from the remote.\n"
|
||||
"\nOnce your repository is up-to-date, retry publishing the tool."
|
||||
)
|
||||
raise SystemExit()
|
||||
|
||||
project_name = get_project_name(require=True)
|
||||
assert isinstance(project_name, str)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user