scripts.go
func bashScript(gitSSHPath string, repo *Repo, params []string) []byte {
	scriptTemplate := `#!/usr/bin/env {shell}

mkdir -p ~/.ssh;
touch ~/.ssh/known_hosts;
ssh-keyscan -t rsa,dsa {repo_host} 2>&1 | sort -u - ~/.ssh/known_hosts > ~/.ssh/tmp_hosts;
cat ~/.ssh/tmp_hosts | while read line
do
  grep -q "$line" ~/.ssh/known_hosts || echo $line >> ~/.ssh/known_hosts;
done
{git_ssh_path} -i {ssh_key_path} {ssh_params};
`
	replacer := strings.NewReplacer(
		"{shell}", shell,
		"{repo_host}", repo.Host,
		"{git_ssh_path}", gitSSHPath,
		"{ssh_key_path}", repo.KeyPath,
		"{ssh_params}", strings.Join(params, " "),
	)
	return []byte(replacer.Replace(scriptTemplate))
}
func bashScript(gitSSHPath string, repo *Repo, params []string) []byte {
	scriptTemplate := `#!/usr/bin/env {shell}

mkdir -p ~/.ssh;
touch ~/.ssh/known_hosts;
ssh-keyscan -t rsa,dsa {repo_host} 2>&1 | sort -u - ~/.ssh/known_hosts > ~/.ssh/tmp_hosts;
cat ~/.ssh/tmp_hosts | while read line
do
  grep -q "$line" ~/.ssh/known_hosts || echo $line >> ~/.ssh/known_hosts;
done
{git_ssh_path} -i {ssh_key_path} {ssh_params};
`
	replacer := strings.NewReplacer(
		"{shell}", shell,
		"{repo_host}", repo.Host,
		"{git_ssh_path}", gitSSHPath,
		"{ssh_key_path}", repo.KeyPath,
		"{ssh_params}", strings.Join(params, " "),
	)
	return []byte(replacer.Replace(scriptTemplate))
}
// bashScript forms content of bash script to clone or update a repo using ssh