I have a complicated command that I want to run with subprocess. It contains single and double quotes and I want to drop in some variables.
This is the string:
gitlab create_merge_request 5 "{} - New merge request - {}" "{source_branch: '{}', target_branch: 'dev', assignee_id: 1}" --json
I want to maintain the quotes around the 'New merge request' section (it contains two variables and around the 'source_branch' variable. The curly braces in the 'source_branch' section are also causing problems.
When I format the string like this:
gitLabCreateMerge = ('/usr/local/bin/gitlab create_merge_request 5 ', str(committerUser), ' requested - Automated Merge Request- ', str(reviewerUser), "'{source_branch:", str(branchName), " target_branch: 'dev', assignee_id: 1}' --json")
It looks like this:
('/usr/local/bin/gitlab create_merge_request 5 ', 'alice', ' requested - Automated merge request - joe ', "'{source_branch:", 'testdevbranch', " target_branch: 'dev', assignee_id: 1}' --json")