ai-cr 3.1.1__py3-none-any.whl → 3.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ai-cr
3
- Version: 3.1.1
3
+ Version: 3.1.2
4
4
  Summary: AI code review tool that works with any language model provider. It detects issues in GitHub pull requests or local changes—instantly, reliably, and without vendor lock-in.
5
5
  License: MIT
6
6
  Keywords: static code analysis,code review,code quality,ai,coding,assistant,llm,github,automation,devops,developer tools,github actions,workflows,git
@@ -4,7 +4,7 @@ gito/bootstrap.py,sha256=m8g7e4sacTe7SsRKmDms1_L2ESF8TAas1lMaH3hvrl8,3218
4
4
  gito/cli.py,sha256=D0XZ7H1Xo6Q7dOL0rC6mJVNQuD7C8MAw1E01jnZXbSw,7072
5
5
  gito/cli_base.py,sha256=h0CvkfOaIYGArqNuKyAuDcJDx-hOB7H7uyfJV3afINg,2390
6
6
  gito/commands/__init__.py,sha256=B2uUQsLMEsHfNT1N3lWYm38WSuQIHFmjiGs2tdBuDBA,55
7
- gito/commands/deploy.py,sha256=PbNcw7Ccau2Bncpi121YDRz9gg9xvkrviytrAEFfpmw,3749
7
+ gito/commands/deploy.py,sha256=JuGLqw3-Mk9cH_BBAkojHBLcAWfOnvBzxW7IQZM8H5U,4913
8
8
  gito/commands/fix.py,sha256=C4imdS776yl7g-KmH9Wu2PqeN4WNJh8NvSeV3pV-63g,5304
9
9
  gito/commands/gh_post_review_comment.py,sha256=xrCauuifrUEufBjx43sw5FMtWP9seHiGYzwAq5SFnvQ,3795
10
10
  gito/commands/gh_react_to_comment.py,sha256=QAc5cZOu9GfPtbEOWH6dQYhsgFSSWFWzzZ1RPNzHxFA,7090
@@ -32,8 +32,8 @@ gito/tpl/questions/changes_summary.j2,sha256=N80OQoo9UKii0CWLuck5bOwbijul5RefvCq
32
32
  gito/tpl/questions/release_notes.j2,sha256=20QtQwdZYcFEjmfYxTysenY-njTPl2nmHpv9077WFdg,849
33
33
  gito/tpl/questions/testing_guide.j2,sha256=AVnl7MoFrRxrH2A83PgV-l7VxqPE6XNRh7VksjE50as,832
34
34
  gito/utils.py,sha256=OSBn7IeWKjoLJoGOcdgQcJHBA69UiHUChtaYMInUeko,6852
35
- ai_cr-3.1.1.dist-info/LICENSE,sha256=VbdF_GbbDK24JvdTfnsxa2M6jmhsxmRSFeHCx-lICGE,1075
36
- ai_cr-3.1.1.dist-info/METADATA,sha256=PZrnP1catEWRFiD5cjUTjCBYfydpPeLZkqFZeFQfQ-k,7989
37
- ai_cr-3.1.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
38
- ai_cr-3.1.1.dist-info/entry_points.txt,sha256=Ua1DxkhJJ8TZuLgnH-IlWCkrre_0S0dq_GtYRaYupWk,38
39
- ai_cr-3.1.1.dist-info/RECORD,,
35
+ ai_cr-3.1.2.dist-info/LICENSE,sha256=VbdF_GbbDK24JvdTfnsxa2M6jmhsxmRSFeHCx-lICGE,1075
36
+ ai_cr-3.1.2.dist-info/METADATA,sha256=HHiTm0njhVeKyLE-nryAPsNLcXIhXqANJGcscvJ8soM,7989
37
+ ai_cr-3.1.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
38
+ ai_cr-3.1.2.dist-info/entry_points.txt,sha256=Ua1DxkhJJ8TZuLgnH-IlWCkrre_0S0dq_GtYRaYupWk,38
39
+ ai_cr-3.1.2.dist-info/RECORD,,
gito/commands/deploy.py CHANGED
@@ -1,16 +1,31 @@
1
+ import logging
1
2
  from pathlib import Path
2
3
 
3
4
  import microcore as mc
4
5
  from microcore import ApiType, ui, utils
5
- from git import Repo
6
+ from git import Repo, GitCommandError
7
+ import typer
6
8
 
9
+ from ..core import get_base_branch
7
10
  from ..utils import version, extract_gh_owner_repo
8
11
  from ..cli_base import app
12
+ from ..gh_api import gh_api
9
13
 
10
14
 
11
15
  @app.command(name="deploy", help="Deploy Gito workflows to GitHub Actions")
12
16
  @app.command(name="init", hidden=True)
13
- def deploy(api_type: ApiType = None, commit: bool = None, rewrite: bool = False):
17
+ def deploy(
18
+ api_type: ApiType = None,
19
+ commit: bool = None,
20
+ rewrite: bool = False,
21
+ to_branch: str = typer.Option(
22
+ default="gito_deploy",
23
+ help="Branch name for new PR containing with Gito workflows commit"
24
+ ),
25
+ token: str = typer.Option(
26
+ "", help="GitHub token (or set GITHUB_TOKEN env var)"
27
+ ),
28
+ ):
14
29
  repo = Repo(".")
15
30
  workflow_files = dict(
16
31
  code_review=Path(".github/workflows/gito-code-review.yml"),
@@ -77,16 +92,35 @@ def deploy(api_type: ApiType = None, commit: bool = None, rewrite: bool = False)
77
92
  "Do you want to commit and push created GitHub workflows to a new branch?"
78
93
  ):
79
94
  repo.git.add([str(file) for file in workflow_files.values()])
80
- branch_name = "gito_deploy"
81
- if not repo.active_branch.name.startswith(branch_name):
82
- repo.git.checkout("-b", branch_name)
83
- repo.git.commit("-m", "Deploy Gito workflows")
84
- repo.git.push("origin", branch_name)
85
- print(f"Changes pushed to {branch_name} branch.")
86
- print(
87
- f"Please create a PR from {branch_name} to your main branch and merge it:\n"
88
- f"https://github.com/{owner}/{repo_name}/compare/gito_deploy?expand=1"
89
- )
95
+ if not repo.active_branch.name.startswith(to_branch):
96
+ repo.git.checkout("-b", to_branch)
97
+ try:
98
+ repo.git.commit("-m", "Deploy Gito workflows")
99
+ except GitCommandError as e:
100
+ if "nothing added" in str(e):
101
+ ui.warning("Failed to commit changes: nothing was added")
102
+ else:
103
+ ui.error(f"Failed to commit changes: {e}")
104
+ return False
105
+
106
+ repo.git.push("origin", to_branch)
107
+ print(f"Changes pushed to {to_branch} branch.")
108
+ try:
109
+ api = gh_api(repo=repo)
110
+ base = get_base_branch(repo).split('/')[-1]
111
+ logging.info(f"Creating PR {ui.green(to_branch)} -> {ui.yellow(base)}...")
112
+ res = api.pulls.create(
113
+ head=to_branch,
114
+ base=base,
115
+ title="Deploy Gito workflows",
116
+ )
117
+ print(f"Pull request #{res.number} created successfully:\n{res.html_url}")
118
+ except Exception as e:
119
+ mc.ui.error(f"Failed to create pull request automatically: {e}")
120
+ print(
121
+ f"Please create a PR from '{to_branch}' to your main branch and merge it:\n"
122
+ f"https://github.com/{owner}/{repo_name}/compare/{to_branch}?expand=1"
123
+ )
90
124
  else:
91
125
  print(
92
126
  "Now you can commit and push created GitHub workflows to your main repository branch.\n"
File without changes
File without changes