【问题标题】:Correct way to pass git log contents with xarg & curl使用 xarg 和 curl 传递 git 日志内容的正确方法
【发布时间】:2023-04-08 11:55:01
【问题描述】:

我想获取 git log 的输出并将其用作 curl 命令的参数。

这是我正在执行的 git log 命令:

git log -1 --format="(%h, %cn): %s"

curl 命令:

curl http://www.example.com -F note='git_log_output'

git log 的输出如下:

(9b42b2f, Author Name): Adding support for fancy stuff

我以为 xargs 会这样做,但执行了这个(暂时使用 echo 而不是 curl):

git log -1 --format="(%h, %cn): %s" | xargs -0 -I {} echo "Hi there {}" 

它实际上打印了这个:

27m" | xargs -0 -I {} echo "Hi {}"Hi (9b42b2f, Author Name): Adding support for fancy stuff

代替:

Hi (9b42b2f, Author Name): Adding support for fancy stuff

有什么好的方法来解决这个问题?

【问题讨论】:

    标签: git command-line xargs


    【解决方案1】:

    curl http://www.example.com -F note="`git log -1 --format="(%h, %cn): %s"`"

    我认为反引号是您想要的。

    【讨论】:

      猜你喜欢
      • 2012-05-13
      • 1970-01-01
      • 2014-07-30
      • 2020-09-20
      • 1970-01-01
      • 2014-10-05
      • 1970-01-01
      • 2016-12-22
      相关资源
      最近更新 更多