cold-mechanic-10814
03/23/2023, 6:05 PM@goal_rule
that I'm implementing. The goal needs to (through one way or another) invoke the git
command to create a git tag. Is that possible, with pants' hermetic workspace? I've read somewhere the docs that you can get a read-only subset of the current git info, but what about calling git commands that will actually modify the state?enough-analyst-54434
03/23/2023, 6:15 PMwitty-crayon-22786
03/23/2023, 6:16 PMInteractiveProcess
directly in your goal, at the top of the stackcold-mechanic-10814
03/23/2023, 6:21 PMInteractiveProcess
, thinking that might be the recommended path, but I was wondering if it's possible to use a 3rd party lib such as GitPython
as it provides some useful abstractions - or is that against the rules of @rules since it modifies things in a what that pants can't monitor?witty-crayon-22786
03/23/2023, 6:22 PMcold-mechanic-10814
03/23/2023, 6:23 PMwitty-crayon-22786
03/23/2023, 6:24 PMcold-mechanic-10814
03/23/2023, 6:25 PMwitty-crayon-22786
03/23/2023, 6:28 PMInteractiveProcess
, Workspace.write_digest
, Console.print
, etc.witty-crayon-22786
03/23/2023, 6:29 PMcold-mechanic-10814
03/23/2023, 6:33 PMGitPython
, it's probably going to break in a future release?witty-crayon-22786
03/23/2023, 6:34 PMcold-mechanic-10814
03/23/2023, 6:35 PMenough-analyst-54434
03/23/2023, 6:35 PMcold-mechanic-10814
03/23/2023, 6:40 PMcold-mechanic-10814
03/23/2023, 6:44 PMclass MyGitHelper:
def __init__(self, repo_path):
self.repo_path
async def some_complex_multistep_op():
...
res1 = await Effect(InteractiveProcessResult, InteractiveProcess(argv=["git something"]),)
...
res2 = await Effect(InteractiveProcessResult, InteractiveProcess(argv=["git something else"]),)
...
return some_retval
@goal_rule
def my_goal(targets: Targets) -> MyGoal:
helper = MyGitHelper(os.cwd())
await helper.some_complex_multistep_op()
witty-crayon-22786
03/23/2023, 6:45 PMwitty-crayon-22786
03/23/2023, 6:46 PMInteractiveProcess
has started, your code will be in a critical section, and not witty-crayon-22786
03/23/2023, 6:47 PMcold-mechanic-10814
03/23/2023, 6:48 PMgit
directly, being able to use existing libs etc. but this is definitely manageable as we only need a couple of specific opscold-mechanic-10814
03/23/2023, 6:49 PMcold-mechanic-10814
03/23/2023, 6:58 PMstdout
of InteractiveProcess
? Say I want to list the git tags via git tags
- it seems that if I do it via Process
it will fail since the .git
directory is not available, but if I do it via InteractiveProcess
I can't retrieve the stdout
witty-crayon-22786
03/23/2023, 6:59 PMwitty-crayon-22786
03/23/2023, 7:00 PMProcess
, and then additionally mark the process uncacheable with ProcessCacheScope
.witty-crayon-22786
03/23/2023, 7:01 PM@goal_rule
cold-mechanic-10814
03/23/2023, 7:03 PMInteractiveProcess
or a Console.print
statement were executed before I invoke any side effects, that would "future-proof" the goal against the upcoming changes? A bit of a hack, but reasonablewitty-crayon-22786
03/23/2023, 7:04 PMcold-mechanic-10814
03/23/2023, 7:04 PM@goal_rule
def my_goal(console: Console) -> MyGoal:
console.print('something')
some_op_with_side_effects_from_a_3rd_party_lib()
witty-crayon-22786
03/23/2023, 7:05 PMwitty-crayon-22786
03/23/2023, 7:05 PMenough-analyst-54434
03/23/2023, 7:06 PMcold-mechanic-10814
03/23/2023, 7:07 PMenough-analyst-54434
03/23/2023, 7:07 PMenough-analyst-54434
03/23/2023, 7:07 PMenough-analyst-54434
03/23/2023, 7:07 PMcold-mechanic-10814
03/23/2023, 7:07 PMenough-analyst-54434
03/23/2023, 7:07 PMenough-analyst-54434
03/23/2023, 7:08 PMenough-analyst-54434
03/23/2023, 7:08 PMenough-analyst-54434
03/23/2023, 7:08 PMcold-mechanic-10814
03/23/2023, 7:08 PMenough-analyst-54434
03/23/2023, 7:09 PMcold-mechanic-10814
03/23/2023, 7:10 PMwitty-crayon-22786
03/23/2023, 7:11 PMdocker_environment
, at which point you would be trapped by Process
.enough-analyst-54434
03/23/2023, 7:12 PMwitty-crayon-22786
03/23/2023, 7:12 PMwitty-crayon-22786
03/23/2023, 7:13 PMenough-analyst-54434
03/23/2023, 7:14 PMcold-mechanic-10814
03/23/2023, 7:17 PMenough-analyst-54434
03/23/2023, 7:18 PMgit tag x
seems to need little abstraction!cold-mechanic-10814
03/23/2023, 7:19 PMenough-analyst-54434
03/23/2023, 7:19 PMcold-mechanic-10814
03/23/2023, 7:21 PMenough-analyst-54434
03/23/2023, 7:22 PMenough-analyst-54434
03/23/2023, 7:22 PMcold-mechanic-10814
03/23/2023, 7:22 PMcold-mechanic-10814
03/23/2023, 7:23 PMcold-mechanic-10814
03/23/2023, 7:23 PMenough-analyst-54434
03/23/2023, 7:23 PMcold-mechanic-10814
03/23/2023, 7:24 PMcold-mechanic-10814
03/23/2023, 7:24 PMenough-analyst-54434
03/23/2023, 7:25 PMgit tag x
and, roughly, git log -- $(pants filedeps)
.enough-analyst-54434
03/23/2023, 7:25 PMcold-mechanic-10814
03/23/2023, 7:26 PMfix: bug 123
or feat: richer reports
cold-mechanic-10814
03/23/2023, 7:26 PMcold-mechanic-10814
03/23/2023, 7:27 PMenough-analyst-54434
03/23/2023, 7:27 PMcold-mechanic-10814
03/23/2023, 7:28 PMenough-analyst-54434
03/23/2023, 7:28 PMenough-analyst-54434
03/23/2023, 7:29 PMenough-analyst-54434
03/23/2023, 7:29 PMcold-mechanic-10814
03/23/2023, 7:29 PMenough-analyst-54434
03/23/2023, 7:30 PMcold-mechanic-10814
03/23/2023, 7:30 PMenough-analyst-54434
03/23/2023, 7:30 PMcold-mechanic-10814
03/23/2023, 7:31 PMcold-mechanic-10814
03/23/2023, 7:31 PMenough-analyst-54434
03/23/2023, 7:33 PMcold-mechanic-10814
03/23/2023, 7:35 PMcold-mechanic-10814
03/23/2023, 7:36 PM