Reimond Hill
Reimond Hill

Reputation: 4760

Git tag with value containing brackets produces: syntax error near unexpected token `('

At the company I am working for we are using a tag convention like that:

WhiteLabel_iOS_V.V(B)

Where V is the version and B is the build number. We also add the platform because we are handling different ones.

Until now, we have been using GitKraken and/or SourceTree. However, we are introducing CI/CD and I am aiming to be able to follow the same tag naming conventions. The CI/CD pipeline is done with GitHub actions and it uses a ruby module that execute all the sh actions using system

Using the sh command on the terminal:

git tag –a WhiteLabel_iOS_3.9(3) -m “WhiteLabel_iOS_3.9(3)”

produces the following error:

syntax error near unexpected token `('

However, executing it like that:

git tag –a WhiteLabel_iOS_3.9\(3\) -m "WhiteLabel_iOS_3.9(3)"

It seems to work.

I have tried the following command in Ruby:

success = system("git tag –a WhiteLabel_iOS_3.9\(3\)")

But it doesn't work...

Any ideas?

Upvotes: 1

Views: 933

Answers (3)

Reimond Hill
Reimond Hill

Reputation: 4760

If using system in ruby, then:

tag_name = "WhiteLabel_iOS_3.9(4)"
success = system("git tag -a \"#{tag_name}\" -m \"#{tag_name}\"; git push origin \"#{tag_name}\"")

Upvotes: 0

Ritchid Amoah
Ritchid Amoah

Reputation: 83

Your 'success' command is missing a closing parenthesis.

it should rather look like this;

success = system("git tag –a WhiteLabel_iOS_3.9\(3\)")

Upvotes: 0

1615903
1615903

Reputation: 34732

Use quotes:

git tag –a "WhiteLabel_iOS_3.9(3)" -m "WhiteLabel_iOS_3.9(3)"

Upvotes: 3

Related Questions