nosarthur / gita

Manage many git repos with sanity 从容管理多个git库
MIT License
1.66k stars 73 forks source link

Request: Ability to run shell commands asynchronously. Also custom commands do not seem to work properly if the command does not start with "git <custom_args>". #263

Open s7jones opened 11 months ago

s7jones commented 11 months ago

I find Gita very useful and I use it to run a script to update various git repos using:

gita shell "powershell "C:\dev\git-ffwd\git-ffwd.ps1""

But that gita shell mode runs the script against each repo synchronously, and I want it to run async.

I looked into the custom commands and tried to add the following:

{
  "ffwd":{
    "cmd": "powershell \"C:\\dev\\git-ffwd\\git-ffwd.ps1\"",
    "allow_all": true,
    "shell": true,
    "help": "fast forward the git repos using custom script"
  }
}

But it didn't work.

It was failing on args.cmd[1] in args.async_blacklist: in main.py, it looks like that code assumes that the first command must be a git command.

I tried to add a simple git command to the front of the custom command, e.g.:

{
  "ffwd": {
    "cmd": "git fetch --all --prune --progress --tags; powershell \"C:\\dev\\git-ffwd\\git-ffwd.ps1\"",
    "allow_all": true,
    "shell": true,
    "help": "fast forward the git repos using custom script"
  }
}

But that still didn't work.


If you could offer a way to make shell commands run asynchronously, either by the custom command format or via the git shell format that would be a great improvement for my workflow.

PS. Thank you for the tool, it saves time during my dev workflows.

nosarthur commented 11 months ago

I tried this and it kinda works. The fetch actually fails but pwd is executed correctly

  "ffwd": {
    "cmd": "git fetch ; pwd",
    "allow_all": true,
    "help": "fast forward the git repos using custom script"
  }
nosarthur commented 11 months ago

sorry it doesn't work, the repo path is printed out by default

nosarthur commented 11 months ago

Maybe there is no workaround; we will need to copy the async logic to gita shell

Ismailou commented 10 months ago

Hello,

I'm using gita since a while now and I find it very helpful in mutli repo projects.

to rejoin s7jones issue, I also tried the custom command fetchcrt in the readme.md but it didn't work also. However some simple command like "git status" works fine.

image

Is there any workaround please, I'm interested in running shell commands. Also it will be intersecting if external commands can take arguments e.g. gita custom_cmd agr1 agr2

Regards,

nosarthur commented 10 months ago

@Ismailou just curious, what kind of shell command do you want to run in each repo?

Ismailou commented 10 months ago

what

I tried the command of fetchcrt example in the readme

    "fetchcrt":
    {
      "cmd": "git rev-parse --abbrev-ref HEAD | xargs git fetch --prune upstream",
      "allow_all": true,
      "shell": true,
      "help": "fetch current branch only"
    }

I tried it on Windows 10 machine in bash, powershell and git Bash the same result.

Regards,