Issue
I have a list of Subversion Repositories that I am converting to GIT, and I have an array of SVN repository paths (which is what the range is on my for loop), and I am having it scrap the path so that I just have the repository name (what the repo_name=${i##*/}
) is for, and then I have it make what the endgame URL is to be for the repository (the URL variable assignment), then I'm using the git API commands to create on GitHub a repository, which is where my issue is.
I need the curl --data
command to name the repository what ever the value of repo_name
is at that moment in the for loop. I guess the issue is that I have a variable inside of the string. I need to get the repo_name
value to be what it names the repository, because right now it names the repository -repo_name
.
for i in "${svn_repos[@]}";
do
repo_name=${i##*/}
url="https://github.com/jjohnson304/${repo_name}.git"
curl --data '{"name":"${repo_name}"}' -X POST -u jjohnson304 https://api.github.com/user/repos
git svn clone $i
git remote add origin ${url}
git push -u origin master
done
Solution
Variables are not expanded inside of single quotes. You need to use double quotes for the --data
argument, with the quotes inside it escaped as \"
.
curl --data "{\"name\":\"${repo_name}\"}" -X POST -u jjohnson304 https://api.github.com/user/repos
Answered By - John Kugelman Answer Checked By - Timothy Miller (WPSolving Admin)