zrb 1.0.0a5__py3-none-any.whl → 1.0.0a8__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.
- zrb/builtin/git.py +16 -13
- zrb/builtin/git_subtree.py +19 -4
- zrb/builtin/group.py +9 -0
- zrb/builtin/todo.py +0 -1
- zrb/config.py +1 -1
- zrb/runner/web_app.py +0 -6
- zrb/task/any_task.py +38 -2
- zrb/task/base_task.py +71 -4
- zrb/util/git.py +35 -17
- zrb/util/git_subtree.py +11 -10
- {zrb-1.0.0a5.dist-info → zrb-1.0.0a8.dist-info}/METADATA +1 -1
- {zrb-1.0.0a5.dist-info → zrb-1.0.0a8.dist-info}/RECORD +14 -14
- {zrb-1.0.0a5.dist-info → zrb-1.0.0a8.dist-info}/WHEEL +0 -0
- {zrb-1.0.0a5.dist-info → zrb-1.0.0a8.dist-info}/entry_points.txt +0 -0
zrb/builtin/git.py
CHANGED
@@ -11,6 +11,7 @@ from zrb.util.git import (
|
|
11
11
|
get_branches,
|
12
12
|
get_current_branch,
|
13
13
|
get_diff,
|
14
|
+
get_repo_dir,
|
14
15
|
pull,
|
15
16
|
push,
|
16
17
|
)
|
@@ -55,7 +56,8 @@ from zrb.util.git import (
|
|
55
56
|
alias="diff",
|
56
57
|
)
|
57
58
|
def get_git_diff(ctx: AnyContext):
|
58
|
-
|
59
|
+
repo_dir = get_repo_dir()
|
60
|
+
diff = get_diff(repo_dir, ctx.input.source, ctx.input.current)
|
59
61
|
result = []
|
60
62
|
decorated = []
|
61
63
|
if ctx.input.created and diff.created:
|
@@ -82,14 +84,15 @@ def get_git_diff(ctx: AnyContext):
|
|
82
84
|
alias="prune",
|
83
85
|
)
|
84
86
|
def prune_local_branches(ctx: AnyContext):
|
85
|
-
|
86
|
-
|
87
|
+
repo_dir = get_repo_dir()
|
88
|
+
branches = get_branches(repo_dir)
|
89
|
+
current_branch = get_current_branch(repo_dir)
|
87
90
|
for branch in branches:
|
88
91
|
if branch == current_branch or branch == "main" or branch == "master":
|
89
92
|
continue
|
90
93
|
ctx.print(stylize_yellow(f"Removing local branch: {branch}"))
|
91
94
|
try:
|
92
|
-
delete_branch(branch)
|
95
|
+
delete_branch(repo_dir, branch)
|
93
96
|
except Exception as e:
|
94
97
|
ctx.log_error(e)
|
95
98
|
|
@@ -107,13 +110,11 @@ def prune_local_branches(ctx: AnyContext):
|
|
107
110
|
alias="commit",
|
108
111
|
)
|
109
112
|
def git_commit(ctx: AnyContext):
|
113
|
+
repo_dir = get_repo_dir()
|
110
114
|
ctx.print("Add changes to staging")
|
111
|
-
add()
|
115
|
+
add(repo_dir)
|
112
116
|
ctx.print("Commit changes")
|
113
|
-
|
114
|
-
commit(ctx.input.message)
|
115
|
-
except Exception as e:
|
116
|
-
ctx.log_error(e)
|
117
|
+
commit(repo_dir, ctx.input.message)
|
117
118
|
|
118
119
|
|
119
120
|
@make_task(
|
@@ -130,10 +131,11 @@ def git_commit(ctx: AnyContext):
|
|
130
131
|
alias="pull",
|
131
132
|
)
|
132
133
|
def git_pull(ctx: AnyContext):
|
134
|
+
repo_dir = get_repo_dir()
|
133
135
|
remote = ctx.input.remote
|
134
|
-
current_branch = get_current_branch()
|
136
|
+
current_branch = get_current_branch(repo_dir)
|
135
137
|
ctx.print(f"Pulling from {remote}/{current_branch}")
|
136
|
-
pull(remote, current_branch)
|
138
|
+
pull(repo_dir, remote, current_branch)
|
137
139
|
|
138
140
|
|
139
141
|
@make_task(
|
@@ -150,7 +152,8 @@ def git_pull(ctx: AnyContext):
|
|
150
152
|
alias="push",
|
151
153
|
)
|
152
154
|
def git_push(ctx: AnyContext):
|
155
|
+
repo_dir = get_repo_dir()
|
153
156
|
remote = ctx.input.remote
|
154
|
-
current_branch = get_current_branch()
|
157
|
+
current_branch = get_current_branch(repo_dir)
|
155
158
|
ctx.print(f"Pushing to {remote}/{current_branch}")
|
156
|
-
push(remote, current_branch)
|
159
|
+
push(repo_dir, remote, current_branch)
|
zrb/builtin/git_subtree.py
CHANGED
@@ -3,6 +3,7 @@ from zrb.builtin.group import git_subtree_group
|
|
3
3
|
from zrb.context.any_context import AnyContext
|
4
4
|
from zrb.input.str_input import StrInput
|
5
5
|
from zrb.task.make_task import make_task
|
6
|
+
from zrb.util.git import get_repo_dir
|
6
7
|
from zrb.util.git_subtree import add_subtree, load_config, pull_subtree, push_subtree
|
7
8
|
|
8
9
|
|
@@ -32,7 +33,9 @@ from zrb.util.git_subtree import add_subtree, load_config, pull_subtree, push_su
|
|
32
33
|
alias="add",
|
33
34
|
)
|
34
35
|
def git_add_subtree(ctx: AnyContext):
|
36
|
+
repo_dir = get_repo_dir()
|
35
37
|
add_subtree(
|
38
|
+
repo_dir=repo_dir,
|
36
39
|
name=ctx.input.name,
|
37
40
|
repo_url=ctx.input["repo-url"],
|
38
41
|
branch=ctx.input["repo-branch"],
|
@@ -48,14 +51,20 @@ def git_add_subtree(ctx: AnyContext):
|
|
48
51
|
alias="pull",
|
49
52
|
)
|
50
53
|
def git_pull_subtree(ctx: AnyContext):
|
51
|
-
|
54
|
+
repo_dir = get_repo_dir()
|
55
|
+
config = load_config(repo_dir)
|
52
56
|
if not config.data:
|
53
57
|
raise ValueError("No subtree config found")
|
54
58
|
first_err: Exception | None = None
|
55
59
|
for name, detail in config.data.items():
|
56
60
|
try:
|
57
61
|
ctx.print(f"Pull from subtree {name}")
|
58
|
-
pull_subtree(
|
62
|
+
pull_subtree(
|
63
|
+
repo_dir=repo_dir,
|
64
|
+
prefix=detail.prefix,
|
65
|
+
repo_url=detail.repo_url,
|
66
|
+
branch=detail.branch,
|
67
|
+
)
|
59
68
|
except Exception as e:
|
60
69
|
if first_err is None:
|
61
70
|
first_err = e
|
@@ -72,14 +81,20 @@ def git_pull_subtree(ctx: AnyContext):
|
|
72
81
|
alias="push",
|
73
82
|
)
|
74
83
|
def git_push_subtree(ctx: AnyContext):
|
75
|
-
|
84
|
+
repo_dir = get_repo_dir()
|
85
|
+
config = load_config(repo_dir)
|
76
86
|
if not config.data:
|
77
87
|
raise ValueError("No subtree config found")
|
78
88
|
first_err: Exception | None = None
|
79
89
|
for name, detail in config.data.items():
|
80
90
|
try:
|
81
91
|
ctx.print(f"Push to subtree {name}")
|
82
|
-
push_subtree(
|
92
|
+
push_subtree(
|
93
|
+
repo_dir=repo_dir,
|
94
|
+
prefix=detail.prefix,
|
95
|
+
repo_url=detail.repo_url,
|
96
|
+
branch=detail.branch,
|
97
|
+
)
|
83
98
|
except Exception as e:
|
84
99
|
if first_err is None:
|
85
100
|
first_err = e
|
zrb/builtin/group.py
CHANGED
@@ -32,3 +32,12 @@ add_to_project_group = project_group.add_group(
|
|
32
32
|
add_fastapp_to_project_group = add_to_project_group.add_group(
|
33
33
|
Group(name="fastapp", description="🚀 Add Fastapp resources")
|
34
34
|
)
|
35
|
+
|
36
|
+
setup_group = cli.add_group(Group(name="setup", description="🛠️ Setup"))
|
37
|
+
setup_system_group = setup_group.add_group(
|
38
|
+
Group(name="system", description="🛠️ Setup system")
|
39
|
+
)
|
40
|
+
setup_dev_group = setup_group.add_group(Group(name="dev", description="🧑💻 Setup dev"))
|
41
|
+
setup_service_group = setup_group.add_group(
|
42
|
+
Group(name="services", description="🌐 Setup services")
|
43
|
+
)
|
zrb/builtin/todo.py
CHANGED
@@ -156,7 +156,6 @@ def todo_log(ctx: AnyContext):
|
|
156
156
|
todo_task = cascade_todo_task(todo_task)
|
157
157
|
current_duration = todo_task.keyval.get("duration", "0")
|
158
158
|
todo_task.keyval["duration"] = add_durations(current_duration, ctx.input.duration)
|
159
|
-
print(current_duration, todo_task.keyval)
|
160
159
|
# Save todo list
|
161
160
|
save_todo_list(todo_file_path, todo_list)
|
162
161
|
# Add log work
|
zrb/config.py
CHANGED
@@ -77,7 +77,7 @@ BANNER = f"""
|
|
77
77
|
zzzzz rr bbbbbb {VERSION} Janggala
|
78
78
|
_ _ . . . _ . _ . . .
|
79
79
|
|
80
|
-
|
80
|
+
Your Automation Powerhouse
|
81
81
|
|
82
82
|
☕ Donate at: https://stalchmst.com/donation
|
83
83
|
🐙 Submit issues/PR at: https://github.com/state-alchemists/zrb
|
zrb/runner/web_app.py
CHANGED
@@ -142,9 +142,3 @@ def create_app(root_group: AnyGroup, port: int = WEB_HTTP_PORT):
|
|
142
142
|
raise HTTPException(status_code=500, detail=str(e))
|
143
143
|
|
144
144
|
return app
|
145
|
-
|
146
|
-
|
147
|
-
# async def run_web_server(app: FastAPI, port: int = WEB_HTTP_PORT):
|
148
|
-
# config = Config(app=app, host="0.0.0.0", port=port, loop="asyncio")
|
149
|
-
# server = Server(config)
|
150
|
-
# await server.serve()
|
zrb/task/any_task.py
CHANGED
@@ -74,6 +74,12 @@ class AnyTask(ABC):
|
|
74
74
|
"""Task fallbacks"""
|
75
75
|
pass
|
76
76
|
|
77
|
+
@property
|
78
|
+
@abstractmethod
|
79
|
+
def successors(self) -> list["AnyTask"]:
|
80
|
+
"""Task successors"""
|
81
|
+
pass
|
82
|
+
|
77
83
|
@property
|
78
84
|
@abstractmethod
|
79
85
|
def readiness_checks(self) -> list["AnyTask"]:
|
@@ -81,8 +87,38 @@ class AnyTask(ABC):
|
|
81
87
|
pass
|
82
88
|
|
83
89
|
@abstractmethod
|
84
|
-
def
|
85
|
-
"""
|
90
|
+
def append_fallback(self, fallbacks: "AnyTask" | list["AnyTask"]):
|
91
|
+
"""Add the fallback tasks.
|
92
|
+
|
93
|
+
Args:
|
94
|
+
fallbacks (AnyTask | list[AnyTask]): A single fallback task or
|
95
|
+
a list of fallback tasks.
|
96
|
+
"""
|
97
|
+
pass
|
98
|
+
|
99
|
+
@abstractmethod
|
100
|
+
def append_successor(self, successors: "AnyTask" | list["AnyTask"]):
|
101
|
+
"""Add the successor tasks.
|
102
|
+
|
103
|
+
Args:
|
104
|
+
successors (AnyTask | list[AnyTask]): A single successor task or
|
105
|
+
a list of successor tasks.
|
106
|
+
"""
|
107
|
+
pass
|
108
|
+
|
109
|
+
@abstractmethod
|
110
|
+
def append_readiness_check(self, readiness_checks: "AnyTask" | list["AnyTask"]):
|
111
|
+
"""Add the readiness_check tasks.
|
112
|
+
|
113
|
+
Args:
|
114
|
+
readiness_checks (AnyTask | list[AnyTask]): A single readiness_check task or
|
115
|
+
a list of readiness_check tasks.
|
116
|
+
"""
|
117
|
+
pass
|
118
|
+
|
119
|
+
@abstractmethod
|
120
|
+
def append_upstream(self, upstreams: "AnyTask" | list["AnyTask"]):
|
121
|
+
"""Add the upstream tasks that this task depends on.
|
86
122
|
|
87
123
|
Args:
|
88
124
|
upstreams (AnyTask | list[AnyTask]): A single upstream task or
|
zrb/task/base_task.py
CHANGED
@@ -38,6 +38,7 @@ class BaseTask(AnyTask):
|
|
38
38
|
monitor_readiness: bool = False,
|
39
39
|
upstream: list[AnyTask] | AnyTask | None = None,
|
40
40
|
fallback: list[AnyTask] | AnyTask | None = None,
|
41
|
+
successor: list[AnyTask] | AnyTask | None = None,
|
41
42
|
):
|
42
43
|
self._name = name
|
43
44
|
self._color = color
|
@@ -50,6 +51,7 @@ class BaseTask(AnyTask):
|
|
50
51
|
self._retry_period = retry_period
|
51
52
|
self._upstreams = upstream
|
52
53
|
self._fallbacks = fallback
|
54
|
+
self._successors = successor
|
53
55
|
self._readiness_checks = readiness_check
|
54
56
|
self._readiness_check_delay = readiness_check_delay
|
55
57
|
self._readiness_check_period = readiness_check_period
|
@@ -65,17 +67,17 @@ class BaseTask(AnyTask):
|
|
65
67
|
def __rshift__(self, other: AnyTask | list[AnyTask]) -> AnyTask:
|
66
68
|
try:
|
67
69
|
if isinstance(other, AnyTask):
|
68
|
-
other.
|
70
|
+
other.append_upstream(self)
|
69
71
|
elif isinstance(other, list):
|
70
72
|
for task in other:
|
71
|
-
task.
|
73
|
+
task.append_upstream(self)
|
72
74
|
return other
|
73
75
|
except Exception as e:
|
74
76
|
raise ValueError(f"Invalid operation {self} >> {other}: {e}")
|
75
77
|
|
76
78
|
def __lshift__(self, other: AnyTask | list[AnyTask]) -> AnyTask:
|
77
79
|
try:
|
78
|
-
self.
|
80
|
+
self.append_upstream(other)
|
79
81
|
return self
|
80
82
|
except Exception as e:
|
81
83
|
raise ValueError(f"Invalid operation {self} << {other}: {e}")
|
@@ -142,6 +144,44 @@ class BaseTask(AnyTask):
|
|
142
144
|
return [self._fallbacks]
|
143
145
|
return self._fallbacks
|
144
146
|
|
147
|
+
def append_fallback(self, fallbacks: AnyTask | list[AnyTask]):
|
148
|
+
fallback_list = [fallbacks] if isinstance(fallbacks, AnyTask) else fallbacks
|
149
|
+
for fallback in fallback_list:
|
150
|
+
self.__append_fallback(fallback)
|
151
|
+
|
152
|
+
def __append_fallback(self, fallback: AnyTask):
|
153
|
+
# Make sure self._fallbacks is a list
|
154
|
+
if self._fallbacks is None:
|
155
|
+
self._fallbacks = []
|
156
|
+
elif isinstance(self._fallbacks, AnyTask):
|
157
|
+
self._fallbacks = [self._fallbacks]
|
158
|
+
# Add fallback if it was not on self._fallbacks
|
159
|
+
if fallback not in self._fallbacks:
|
160
|
+
self._fallbacks.append(fallback)
|
161
|
+
|
162
|
+
@property
|
163
|
+
def successors(self) -> list[AnyTask]:
|
164
|
+
if self._successors is None:
|
165
|
+
return []
|
166
|
+
elif isinstance(self._successors, AnyTask):
|
167
|
+
return [self._successors]
|
168
|
+
return self._successors
|
169
|
+
|
170
|
+
def append_successor(self, successors: AnyTask | list[AnyTask]):
|
171
|
+
successor_list = [successors] if isinstance(successors, AnyTask) else successors
|
172
|
+
for successor in successor_list:
|
173
|
+
self.__append_successor(successor)
|
174
|
+
|
175
|
+
def __append_successor(self, successor: AnyTask):
|
176
|
+
# Make sure self._successors is a list
|
177
|
+
if self._successors is None:
|
178
|
+
self._successors = []
|
179
|
+
elif isinstance(self._successors, AnyTask):
|
180
|
+
self._successors = [self._successors]
|
181
|
+
# Add successor if it was not on self._successors
|
182
|
+
if successor not in self._successors:
|
183
|
+
self._successors.append(successor)
|
184
|
+
|
145
185
|
@property
|
146
186
|
def readiness_checks(self) -> list[AnyTask]:
|
147
187
|
if self._readiness_checks is None:
|
@@ -150,6 +190,25 @@ class BaseTask(AnyTask):
|
|
150
190
|
return [self._readiness_checks]
|
151
191
|
return self._readiness_checks
|
152
192
|
|
193
|
+
def append_readiness_check(self, readiness_checks: AnyTask | list[AnyTask]):
|
194
|
+
readiness_check_list = (
|
195
|
+
[readiness_checks]
|
196
|
+
if isinstance(readiness_checks, AnyTask)
|
197
|
+
else readiness_checks
|
198
|
+
)
|
199
|
+
for readiness_check in readiness_check_list:
|
200
|
+
self.__append_readiness_check(readiness_check)
|
201
|
+
|
202
|
+
def __append_readiness_check(self, readiness_check: AnyTask):
|
203
|
+
# Make sure self._readiness_checks is a list
|
204
|
+
if self._readiness_checks is None:
|
205
|
+
self._readiness_checks = []
|
206
|
+
elif isinstance(self._readiness_checks, AnyTask):
|
207
|
+
self._readiness_checks = [self._readiness_checks]
|
208
|
+
# Add readiness_check if it was not on self._readiness_checks
|
209
|
+
if readiness_check not in self._readiness_checks:
|
210
|
+
self._readiness_checks.append(readiness_check)
|
211
|
+
|
153
212
|
@property
|
154
213
|
def upstreams(self) -> list[AnyTask]:
|
155
214
|
if self._upstreams is None:
|
@@ -158,7 +217,7 @@ class BaseTask(AnyTask):
|
|
158
217
|
return [self._upstreams]
|
159
218
|
return self._upstreams
|
160
219
|
|
161
|
-
def
|
220
|
+
def append_upstream(self, upstreams: AnyTask | list[AnyTask]):
|
162
221
|
upstream_list = [upstreams] if isinstance(upstreams, AnyTask) else upstreams
|
163
222
|
for upstream in upstream_list:
|
164
223
|
self.__append_upstream(upstream)
|
@@ -374,6 +433,7 @@ class BaseTask(AnyTask):
|
|
374
433
|
# Put result on xcom
|
375
434
|
task_xcom: Xcom = ctx.xcom.get(self.name)
|
376
435
|
task_xcom.push(result)
|
436
|
+
await run_async(self.__exec_successors(session))
|
377
437
|
return result
|
378
438
|
except (asyncio.CancelledError, KeyboardInterrupt):
|
379
439
|
ctx.log_info("Marked as failed")
|
@@ -390,6 +450,13 @@ class BaseTask(AnyTask):
|
|
390
450
|
await run_async(self.__exec_fallbacks(session))
|
391
451
|
raise e
|
392
452
|
|
453
|
+
async def __exec_successors(self, session: AnySession) -> Any:
|
454
|
+
successors: list[AnyTask] = self.successors
|
455
|
+
successor_coros = [
|
456
|
+
run_async(successor.exec_chain(session)) for successor in successors
|
457
|
+
]
|
458
|
+
await asyncio.gather(*successor_coros)
|
459
|
+
|
393
460
|
async def __exec_fallbacks(self, session: AnySession) -> Any:
|
394
461
|
fallbacks: list[AnyTask] = self.fallbacks
|
395
462
|
fallback_coros = [
|
zrb/util/git.py
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import os
|
1
2
|
import subprocess
|
2
3
|
|
3
4
|
from pydantic import BaseModel
|
@@ -9,14 +10,19 @@ class DiffResult(BaseModel):
|
|
9
10
|
updated: list[str]
|
10
11
|
|
11
12
|
|
12
|
-
def get_diff(source_commit: str, current_commit: str) -> DiffResult:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
def get_diff(repo_dir: str, source_commit: str, current_commit: str) -> DiffResult:
|
14
|
+
try:
|
15
|
+
result = subprocess.run(
|
16
|
+
["git", "diff", source_commit, current_commit],
|
17
|
+
stdout=subprocess.PIPE,
|
18
|
+
stderr=subprocess.PIPE,
|
19
|
+
cwd=repo_dir,
|
20
|
+
text=True,
|
21
|
+
check=True,
|
22
|
+
)
|
23
|
+
except subprocess.CalledProcessError as e:
|
24
|
+
raise Exception(e.stderr or e.stdout)
|
25
|
+
lines = result.stdout.strip().split("\n")
|
20
26
|
diff: dict[str, dict[str, bool]] = {}
|
21
27
|
for line in lines:
|
22
28
|
if not line.startswith("---") and not line.startswith("+++"):
|
@@ -55,17 +61,18 @@ def get_repo_dir() -> str:
|
|
55
61
|
check=True,
|
56
62
|
)
|
57
63
|
# Return the directory path
|
58
|
-
return result.stdout.strip()
|
64
|
+
return os.path.abspath(result.stdout.strip())
|
59
65
|
except subprocess.CalledProcessError as e:
|
60
66
|
raise Exception(e.stderr or e.stdout)
|
61
67
|
|
62
68
|
|
63
|
-
def get_current_branch() -> str:
|
69
|
+
def get_current_branch(repo_dir: str) -> str:
|
64
70
|
try:
|
65
71
|
result = subprocess.run(
|
66
72
|
["git", "rev-parse", "--abbrev-ref", "HEAD"],
|
67
73
|
stdout=subprocess.PIPE,
|
68
74
|
stderr=subprocess.PIPE,
|
75
|
+
cwd=repo_dir,
|
69
76
|
text=True,
|
70
77
|
check=True,
|
71
78
|
)
|
@@ -74,12 +81,13 @@ def get_current_branch() -> str:
|
|
74
81
|
raise Exception(e.stderr or e.stdout)
|
75
82
|
|
76
83
|
|
77
|
-
def get_branches() -> list[str]:
|
84
|
+
def get_branches(repo_dir: str) -> list[str]:
|
78
85
|
try:
|
79
86
|
result = subprocess.run(
|
80
87
|
["git", "branch"],
|
81
88
|
stdout=subprocess.PIPE,
|
82
89
|
stderr=subprocess.PIPE,
|
90
|
+
cwd=repo_dir,
|
83
91
|
text=True,
|
84
92
|
check=True,
|
85
93
|
)
|
@@ -90,12 +98,13 @@ def get_branches() -> list[str]:
|
|
90
98
|
raise Exception(e.stderr or e.stdout)
|
91
99
|
|
92
100
|
|
93
|
-
def delete_branch(branch_name: str) -> str:
|
101
|
+
def delete_branch(repo_dir: str, branch_name: str) -> str:
|
94
102
|
try:
|
95
103
|
result = subprocess.run(
|
96
104
|
["git", "branch", "-D", branch_name],
|
97
105
|
stdout=subprocess.PIPE,
|
98
106
|
stderr=subprocess.PIPE,
|
107
|
+
cwd=repo_dir,
|
99
108
|
text=True,
|
100
109
|
check=True,
|
101
110
|
)
|
@@ -104,12 +113,13 @@ def delete_branch(branch_name: str) -> str:
|
|
104
113
|
raise Exception(e.stderr or e.stdout)
|
105
114
|
|
106
115
|
|
107
|
-
def add() -> str:
|
116
|
+
def add(repo_dir: str) -> str:
|
108
117
|
try:
|
109
118
|
subprocess.run(
|
110
119
|
["git", "add", ".", "-A"],
|
111
120
|
stdout=subprocess.PIPE,
|
112
121
|
stderr=subprocess.PIPE,
|
122
|
+
cwd=repo_dir,
|
113
123
|
text=True,
|
114
124
|
check=True,
|
115
125
|
)
|
@@ -117,25 +127,32 @@ def add() -> str:
|
|
117
127
|
raise Exception(e.stderr or e.stdout)
|
118
128
|
|
119
129
|
|
120
|
-
def commit(message: str) -> str:
|
130
|
+
def commit(repo_dir: str, message: str) -> str:
|
121
131
|
try:
|
122
132
|
subprocess.run(
|
123
133
|
["git", "commit", "-m", message],
|
124
134
|
stdout=subprocess.PIPE,
|
125
135
|
stderr=subprocess.PIPE,
|
136
|
+
cwd=repo_dir,
|
126
137
|
text=True,
|
127
138
|
check=True,
|
128
139
|
)
|
129
140
|
except subprocess.CalledProcessError as e:
|
130
|
-
|
141
|
+
ignored_error_message = "nothing to commit, working tree clean"
|
142
|
+
if (
|
143
|
+
ignored_error_message not in e.stderr
|
144
|
+
and ignored_error_message not in e.stdout
|
145
|
+
):
|
146
|
+
raise Exception(e.stderr or e.stdout)
|
131
147
|
|
132
148
|
|
133
|
-
def pull(remote: str, branch: str) -> str:
|
149
|
+
def pull(repo_dir: str, remote: str, branch: str) -> str:
|
134
150
|
try:
|
135
151
|
subprocess.run(
|
136
152
|
["git", "pull", remote, branch],
|
137
153
|
stdout=subprocess.PIPE,
|
138
154
|
stderr=subprocess.PIPE,
|
155
|
+
cwd=repo_dir,
|
139
156
|
text=True,
|
140
157
|
check=True,
|
141
158
|
)
|
@@ -143,12 +160,13 @@ def pull(remote: str, branch: str) -> str:
|
|
143
160
|
raise Exception(e.stderr or e.stdout)
|
144
161
|
|
145
162
|
|
146
|
-
def push(remote: str, branch: str) -> str:
|
163
|
+
def push(repo_dir: str, remote: str, branch: str) -> str:
|
147
164
|
try:
|
148
165
|
subprocess.run(
|
149
166
|
["git", "push", "-u", remote, branch],
|
150
167
|
stdout=subprocess.PIPE,
|
151
168
|
stderr=subprocess.PIPE,
|
169
|
+
cwd=repo_dir,
|
152
170
|
text=True,
|
153
171
|
check=True,
|
154
172
|
)
|
zrb/util/git_subtree.py
CHANGED
@@ -3,8 +3,6 @@ import subprocess
|
|
3
3
|
|
4
4
|
from pydantic import BaseModel
|
5
5
|
|
6
|
-
from zrb.util.git import get_repo_dir
|
7
|
-
|
8
6
|
|
9
7
|
class SingleSubTreeConfig(BaseModel):
|
10
8
|
repo_url: str
|
@@ -16,21 +14,21 @@ class SubTreeConfig(BaseModel):
|
|
16
14
|
data: dict[str, SingleSubTreeConfig]
|
17
15
|
|
18
16
|
|
19
|
-
def load_config() -> SubTreeConfig:
|
20
|
-
file_path = os.path.join(
|
17
|
+
def load_config(repo_dir: str) -> SubTreeConfig:
|
18
|
+
file_path = os.path.join(repo_dir, "subtrees.json")
|
21
19
|
if not os.path.exists(file_path):
|
22
20
|
return SubTreeConfig(data={})
|
23
21
|
with open(file_path, "r") as f:
|
24
22
|
return SubTreeConfig.model_validate_json(f.read())
|
25
23
|
|
26
24
|
|
27
|
-
def save_config(config: SubTreeConfig):
|
28
|
-
file_path = os.path.join(
|
25
|
+
def save_config(repo_dir: str, config: SubTreeConfig):
|
26
|
+
file_path = os.path.join(repo_dir, "subtrees.json")
|
29
27
|
with open(file_path, "w") as f:
|
30
28
|
f.write(config.model_dump_json(indent=2))
|
31
29
|
|
32
30
|
|
33
|
-
def add_subtree(name: str, repo_url: str, branch: str, prefix: str):
|
31
|
+
def add_subtree(repo_dir: str, name: str, repo_url: str, branch: str, prefix: str):
|
34
32
|
config = load_config()
|
35
33
|
if os.path.isdir(prefix):
|
36
34
|
raise ValueError(f"Directory exists: {prefix}")
|
@@ -41,6 +39,7 @@ def add_subtree(name: str, repo_url: str, branch: str, prefix: str):
|
|
41
39
|
["git", "subtree", "add", "--prefix", prefix, repo_url, branch],
|
42
40
|
stdout=subprocess.PIPE,
|
43
41
|
stderr=subprocess.PIPE,
|
42
|
+
cwd=repo_dir,
|
44
43
|
text=True,
|
45
44
|
check=True,
|
46
45
|
)
|
@@ -49,10 +48,10 @@ def add_subtree(name: str, repo_url: str, branch: str, prefix: str):
|
|
49
48
|
config.data[name] = SingleSubTreeConfig(
|
50
49
|
repo_url=repo_url, branch=branch, prefix=prefix
|
51
50
|
)
|
52
|
-
save_config(config)
|
51
|
+
save_config(repo_dir, config)
|
53
52
|
|
54
53
|
|
55
|
-
def pull_subtree(prefix: str, repo_url: str, branch: str):
|
54
|
+
def pull_subtree(repo_dir: str, prefix: str, repo_url: str, branch: str):
|
56
55
|
try:
|
57
56
|
subprocess.run(
|
58
57
|
[
|
@@ -66,6 +65,7 @@ def pull_subtree(prefix: str, repo_url: str, branch: str):
|
|
66
65
|
],
|
67
66
|
stdout=subprocess.PIPE,
|
68
67
|
stderr=subprocess.PIPE,
|
68
|
+
cwd=repo_dir,
|
69
69
|
text=True,
|
70
70
|
check=True,
|
71
71
|
)
|
@@ -73,7 +73,7 @@ def pull_subtree(prefix: str, repo_url: str, branch: str):
|
|
73
73
|
raise Exception(e.stderr or e.stdout)
|
74
74
|
|
75
75
|
|
76
|
-
def push_subtree(prefix: str, repo_url: str, branch: str):
|
76
|
+
def push_subtree(repo_dir: str, prefix: str, repo_url: str, branch: str):
|
77
77
|
try:
|
78
78
|
subprocess.run(
|
79
79
|
[
|
@@ -87,6 +87,7 @@ def push_subtree(prefix: str, repo_url: str, branch: str):
|
|
87
87
|
],
|
88
88
|
stdout=subprocess.PIPE,
|
89
89
|
stderr=subprocess.PIPE,
|
90
|
+
cwd=repo_dir,
|
90
91
|
text=True,
|
91
92
|
check=True,
|
92
93
|
)
|
@@ -4,9 +4,9 @@ zrb/attr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
zrb/attr/type.py,sha256=4TV5gPYMMrKh5V-yB6iRYKCbsXAH_AvGXMsjxKLHcUs,568
|
5
5
|
zrb/builtin/__init__.py,sha256=hBnr175f1UsMFYPeD5GBoyL-uqEUy9jSrtosq87pmkU,1347
|
6
6
|
zrb/builtin/base64.py,sha256=1YnSwASp7OEAvQcsnHZGpJEvYoI1Z2zTIJ1bCDHfcPQ,921
|
7
|
-
zrb/builtin/git.py,sha256=
|
8
|
-
zrb/builtin/git_subtree.py,sha256=
|
9
|
-
zrb/builtin/group.py,sha256=
|
7
|
+
zrb/builtin/git.py,sha256=ypxGT4JyokYbXMvxdWFG684sEa6x7wht1b4PxpddTMA,4544
|
8
|
+
zrb/builtin/git_subtree.py,sha256=M5Fr8NB4LaC3ra997tzZMLeD4H5o84MvvwefrLcWEIk,3016
|
9
|
+
zrb/builtin/group.py,sha256=jf7Z_WWBtvNOEJvrYeXFxdXaW_SJySsb6ZSpYJqpVoA,1806
|
10
10
|
zrb/builtin/llm/llm_chat.py,sha256=ATENrihXUMkQ8IoarhacohUe-I_43yb7c0Tl5f69mAI,1397
|
11
11
|
zrb/builtin/llm/tool/cli.py,sha256=n8THj513k1vrXUoZrTcxESmdZzhBOP1-L3Dmup5ZW54,225
|
12
12
|
zrb/builtin/llm/tool/rag.py,sha256=rpfTMhLpkH9ZEyBcmFqLTz3UB2F6VP6w_Se2mPQVZXM,6845
|
@@ -74,14 +74,14 @@ zrb/builtin/shell/autocomplete/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5
|
|
74
74
|
zrb/builtin/shell/autocomplete/bash.py,sha256=-7YDVV7txgJH9mAYSYN0jmvUEeDIzWFvVNY-cY0myF8,1181
|
75
75
|
zrb/builtin/shell/autocomplete/subcmd.py,sha256=WZI6cGWJcn80zSyxOHG7sCMO3Ucix3mZf4xm_xyB_Y0,606
|
76
76
|
zrb/builtin/shell/autocomplete/zsh.py,sha256=9hlq0Wt3fhRz326mAQTypEd4_4lZdrbBx_3A-Ti3mvw,1022
|
77
|
-
zrb/builtin/todo.py,sha256=
|
77
|
+
zrb/builtin/todo.py,sha256=_mIKFD0Ah37yzDjn5-gbYvdbYLX4g5w4N2LKsz0JV6A,6809
|
78
78
|
zrb/callback/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
79
79
|
zrb/callback/any_callback.py,sha256=Yhdv5UWHAZSVzj5K2JdxcVQx8x8VX8aZJEivj3NTfZc,247
|
80
80
|
zrb/callback/callback.py,sha256=IQ7r9EnXYHHcNXKBJAk4WFqCqj7WDvflAuCyu5y-27I,849
|
81
81
|
zrb/cmd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
82
82
|
zrb/cmd/cmd_result.py,sha256=L8bQJzWCpcYexIxHBNsXj2pT3BtLmWex0iJSMkvimOA,597
|
83
83
|
zrb/cmd/cmd_val.py,sha256=LGuE85zQt0KSjpmW7bwIE5dnfIq-ULB8V2CDAiQ-SFk,960
|
84
|
-
zrb/config.py,sha256=
|
84
|
+
zrb/config.py,sha256=izpT3RQD2ZJBI1aQyNDmbIJ6HBtFzExOUvWfPOIWd4I,2917
|
85
85
|
zrb/content_transformer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
86
86
|
zrb/content_transformer/any_content_transformer.py,sha256=3XHM6ZdsJFXxRD7YlUkv0Gn7-mexsH8c8zdHt3C0x8k,741
|
87
87
|
zrb/content_transformer/content_transformer.py,sha256=8luyLZZneBIBAMgGZvydy0TTjhI-TWFgEiQbuCxCAbk,1640
|
@@ -112,7 +112,7 @@ zrb/input/str_input.py,sha256=NevZHX9rf1g8eMatPyy-kUX3DglrVAQpzvVpKAzf7bA,81
|
|
112
112
|
zrb/input/text_input.py,sha256=te86xFpzIZnWb9xOeKHykNKTbY3pe1CdoaRCKr7UUQM,3054
|
113
113
|
zrb/runner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
114
114
|
zrb/runner/cli.py,sha256=tM61thLwJNfjrHFVJqWmGuzE0MB273JZ8ANlROsKH1E,7024
|
115
|
-
zrb/runner/web_app.py,sha256=
|
115
|
+
zrb/runner/web_app.py,sha256=giULuphQhb_lJP95RiXm5i-Uk9MrnIrSXhRVLK73-8s,5987
|
116
116
|
zrb/runner/web_controller/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
117
117
|
zrb/runner/web_controller/group_info_ui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
118
118
|
zrb/runner/web_controller/group_info_ui/controller.py,sha256=sI1UKnRcr5K-a_lGMm5H54hbhdQwIMLlXYmwfxoIqSY,2831
|
@@ -149,8 +149,8 @@ zrb/session_state_logger/any_session_state_logger.py,sha256=W_G1fCw9ZVj4LRTplTpB
|
|
149
149
|
zrb/session_state_logger/default_session_state_logger.py,sha256=w_cAaNUg1ZmJk-ge1kh3xtag3SApC3ZdB3VbxUvU5Ro,197
|
150
150
|
zrb/session_state_logger/file_session_state_logger.py,sha256=0lMtx7Othu4-jhL_iDHFbZWF_5HX84StU134QNCVgeQ,3753
|
151
151
|
zrb/task/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
152
|
-
zrb/task/any_task.py,sha256=
|
153
|
-
zrb/task/base_task.py,sha256=
|
152
|
+
zrb/task/any_task.py,sha256=9rCdKe-Sayr34Han9AsbhRxFpkbk6Rteg1DOyETulwQ,4917
|
153
|
+
zrb/task/base_task.py,sha256=Vn_MTR5aa3jIEWmh5LXpzezh-JwaEXPbjGKptx-Q-U8,19161
|
154
154
|
zrb/task/base_trigger.py,sha256=milE5BNeIeq8jGCP38qTfstSvrc0CkSnO2sV-vlhzsM,4491
|
155
155
|
zrb/task/cmd_task.py,sha256=3N3pyvz7qZ8lDB9pxGVFvfpubE33hXo48UKSmuZDGc0,10249
|
156
156
|
zrb/task/http_check.py,sha256=TwQCql3589a4-H2c7hgS1HayyU-NdBAdJ4qQNTvjXHM,2474
|
@@ -178,8 +178,8 @@ zrb/util/codemod/add_key_to_dict.py,sha256=ROw7Ds73gP5G5vOYlSqcHGUQQmJP_6Vb2jPnV
|
|
178
178
|
zrb/util/codemod/add_param_to_function_call.py,sha256=cNC16uYbkjl33QEZ7i3pYvifGJXSXEoyfyCYx96S8ZI,1567
|
179
179
|
zrb/util/codemod/add_property_to_class.py,sha256=43ll7b7SUWHPDpIoMp8Zp_I71wG1eAvnW_acp-HVF_4,2075
|
180
180
|
zrb/util/cron.py,sha256=9fTGatUMYCRgmDFGg-z6_XerT4U5Vq72nD05NnEVUm4,2852
|
181
|
-
zrb/util/git.py,sha256=
|
182
|
-
zrb/util/git_subtree.py,sha256=
|
181
|
+
zrb/util/git.py,sha256=QNGvJJ9kY1Hy6WNO4d22D_GXyC1l3yGtTOMJ9nXqqpc,5151
|
182
|
+
zrb/util/git_subtree.py,sha256=DidHZdKcpylomlJLiUyQJSpPSXaY399e-97H0WbOcvs,2619
|
183
183
|
zrb/util/group.py,sha256=Bg7HrSycoK110U5s_Tca6-uUQuZ5CMgb8wxZSrvDQ98,2790
|
184
184
|
zrb/util/llm/tool.py,sha256=9ezbPEAyMKLWABgeqAimJ82KBFl7ciWNFVGhtllXg6s,2106
|
185
185
|
zrb/util/load.py,sha256=VMScnycP8blLFOGXjFAKShbV-yvPXwRA_J2vt96T-wc,1552
|
@@ -191,7 +191,7 @@ zrb/util/string/name.py,sha256=8picJfUBXNpdh64GNaHv3om23QHhUZux7DguFLrXHp8,1163
|
|
191
191
|
zrb/util/todo.py,sha256=Nbe1a-7O5FSkIE7BZxQQt7AhbHFPDbreJJI6C7Rga4o,9171
|
192
192
|
zrb/xcom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
193
193
|
zrb/xcom/xcom.py,sha256=P4aYHdE3FRsTsNrXGyW8N44IWZjw-vG_qys1Ymn3aBg,1572
|
194
|
-
zrb-1.0.
|
195
|
-
zrb-1.0.
|
196
|
-
zrb-1.0.
|
197
|
-
zrb-1.0.
|
194
|
+
zrb-1.0.0a8.dist-info/METADATA,sha256=nETONPRmLoWhOEjid0GHsKoHrrLEECJBTrrnVRFo-7w,4105
|
195
|
+
zrb-1.0.0a8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
196
|
+
zrb-1.0.0a8.dist-info/entry_points.txt,sha256=-Pg3ElWPfnaSM-XvXqCxEAa-wfVI6BEgcs386s8C8v8,46
|
197
|
+
zrb-1.0.0a8.dist-info/RECORD,,
|
File without changes
|
File without changes
|