Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无法匹配已经创建的仓库 #86

Closed
yi-Xu-0100 opened this issue Jan 31, 2021 · 1 comment
Closed

无法匹配已经创建的仓库 #86

yi-Xu-0100 opened this issue Jan 31, 2021 · 1 comment

Comments

@yi-Xu-0100
Copy link
Contributor

yi-Xu-0100 commented Jan 31, 2021

当前的匹配语句是匹配多行,但是 echo 打印的内容并不是多行,使用 grep -Fx 造成无法匹配到已经创建的仓库。造成每次都会创建一次,虽然可能提示已经创建而不会有报错退出。

function create_repo
{
# Auto create non-existing repo
has_repo=`echo $DST_REPOS | grep -Fx $1 | wc -l`
if [ $has_repo == 0 ]; then
echo "Create non-exist repo..."
if [[ "$DST_TYPE" == "github" ]]; then
curl -s -H "Authorization: token $2" --data '{"name":"'$1'"}' $DST_REPO_CREATE_API > /dev/null
elif [[ "$DST_TYPE" == "gitee" ]]; then
curl -s -X POST --header 'Content-Type: application/json;charset=UTF-8' $DST_REPO_CREATE_API -d '{"name": "'$1'","access_token": "'$2'"}' > /dev/null
fi
fi
git remote add $DST_TYPE git@$DST_TYPE.com:$DST_ACCOUNT/$1.git || echo "Remote already exists."
}

@yi-Xu-0100
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant