2

How do I commit a new file to a git repo in Container Builder? The build step seems pretty straightforward:

{
    "name": "gcr.io/cloud-builders/git",
    "args": ["commit", 
            "--author=\"David\ Wynn\ <Remixer96@gmail.com>\"",
            "-am", 
            "Test post"]
}

... but the resulting command wraps the --author in a way that isn't valid:

commit "--author="David Wynn <Remixer96@gmail.com>"" -am "Test post"

Is there another way to pass in an author when committing? Is there an explicit "don't quote this" command for container builder?

Update 01

Edmund below suggests that breaking the equals sign apart should fix this, but the error for an unknown user still gets thrown. The Stack Overflow question here:

Commit without setting user.email and user.name

... suggests this is because the author flag doesn't update the committer, which is required. The new long form should be something like this:

git -c user.name='Paul Draper' -c user.email='my@email.org' commit -m '...'

.... but this brings us back to the original problem because Container Builder doesn't seem able to take a space-separated argument without quoting the whole piece.

Update 02 (Resolved)

For some reason, git seems fine when taking quoted strings for the -c flags, and as such this now works fine in container builder. The step now looks like the following :

{
  "name": "gcr.io/cloud-builders/git",
  "args": ["-c",
          "user.name=\"David\ \Wynn\"",
          "-c",
          "user.email=\"Remixer96@gmail.com\"",
          "commit", 
          "-m", 
          "Test post"]
},
FTWynn
  • 1,349
  • 2
  • 11
  • 11

2 Answers2

1

As posted in the update, git apparently takes quoted string on -c flags, so this now passes in container builder without issue using the following step:

{
  "name": "gcr.io/cloud-builders/git",
  "args": ["-c",
          "user.name=\"David\ \Wynn\"",
          "-c",
          "user.email=\"Remixer96@gmail.com\"",
          "commit", 
          "-m", 
          "Test post"]
},
FTWynn
  • 1,349
  • 2
  • 11
  • 11
0

Splitting the argument into two parts (--author, value) should fix this problem. You can do this for any argument in git that the manual says should be in format "--argument=value".

{
    "name": "gcr.io/cloud-builders/git",
    "args": ["commit", 
            "--author",
            "\"David\ Wynn\ <Remixer96@gmail.com>\"",
            "-am", 
            "Test post"]
}
Edmund Dipple
  • 2,244
  • 17
  • 12
  • While that does create the command: commit --author "David Wynn " -am "Test post" It seems git, as provided by the cloud buidlers at gcr.io/cloud-builders/git, still chokes on it. – FTWynn Dec 15 '17 at 18:57