forked from loafle/openapi-generator-original
Rename csharp-netcore to csharp (#15903)
* rename csharp-netcore to csharp * rename file * renmae modules/openapi-generator/src/main/resources/csharp-netcore * update samples * mv dir * update samples * rename csharp-netcore to csharp in appveyor.yml * update doc
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
param(
|
||||
[Parameter()][Alias("g")][String]$GitHost = "github.com",
|
||||
[Parameter()][Alias("u")][String]$GitUserId = "GIT_USER_ID",
|
||||
[Parameter()][Alias("r")][String]$GitRepoId = "GIT_REPO_ID",
|
||||
[Parameter()][Alias("m")][string]$Message = "Minor update",
|
||||
[Parameter()][Alias("h")][switch]$Help
|
||||
)
|
||||
|
||||
function Publish-ToGitHost{
|
||||
if ([string]::IsNullOrWhiteSpace($Message) -or $Message -eq "Minor update"){
|
||||
# it seems unlikely that we would want our git commit message to be the default, so lets prompt the user
|
||||
$Message = Read-Host -Prompt "Please provide a commit message or press enter"
|
||||
$Message = if([string]::IsNullOrWhiteSpace($Message)) { "no message provided" } else { $Message }
|
||||
}
|
||||
|
||||
git init
|
||||
git add .
|
||||
git commit -am "${Message}"
|
||||
$branchName=$(git rev-parse --abbrev-ref HEAD)
|
||||
$gitRemote=$(git remote)
|
||||
|
||||
if([string]::IsNullOrWhiteSpace($gitRemote)){
|
||||
git remote add origin https://${GitHost}/${GitUserId}/${GitRepoId}.git
|
||||
}
|
||||
|
||||
Write-Output "Pulling from https://${GitHost}/${GitUserId}/${GitRepoId}.git"
|
||||
git pull origin $branchName --ff-only
|
||||
|
||||
if ($LastExitCode -ne 0){
|
||||
if (${GitHost} -eq "github.com"){
|
||||
Write-Output "The ${GitRepoId} repository may not exist yet. Creating it now with the GitHub CLI."
|
||||
gh auth login --hostname github.com --web
|
||||
gh repo create $GitRepoId --private
|
||||
# sleep 2 seconds to ensure git finishes creation of the repo
|
||||
Start-Sleep -Seconds 2
|
||||
}
|
||||
else{
|
||||
throw "There was an issue pulling the origin branch. The remote repository may not exist yet."
|
||||
}
|
||||
}
|
||||
|
||||
Write-Output "Pushing to https://${GitHost}/${GitUserId}/${GitRepoId}.git"
|
||||
git push origin $branchName
|
||||
}
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
Set-StrictMode -Version 3.0
|
||||
|
||||
if ($Help){
|
||||
Write-Output "
|
||||
This script will initialize a git repository, then add and commit all files.
|
||||
The local repository will then be pushed to your preferred git provider.
|
||||
If the remote repository does not exist yet and you are using GitHub,
|
||||
the repository will be created for you provided you have the GitHub CLI installed.
|
||||
|
||||
Parameters:
|
||||
-g | -GitHost -> ex: github.com
|
||||
-m | -Message -> the git commit message
|
||||
-r | -GitRepoId -> the name of the repository
|
||||
-u | -GitUserId -> your user id
|
||||
"
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
$rootPath=Resolve-Path -Path $PSScriptRoot/../..
|
||||
|
||||
Push-Location $rootPath
|
||||
|
||||
try {
|
||||
Publish-ToGitHost $GitHost $GitUserId $GitRepoId $Message
|
||||
}
|
||||
finally{
|
||||
Pop-Location
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=${1:-GIT_USER_ID}
|
||||
git_repo_id=${2:-GIT_REPO_ID}
|
||||
release_note=${3:-Minor update}
|
||||
git_host=${4:-github.com}
|
||||
|
||||
starting_directory=$(pwd)
|
||||
script_root="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||
cd $script_root
|
||||
cd ../..
|
||||
|
||||
if [ "$release_note" = "" ] || [ "$release_note" = "Minor update" ]; then
|
||||
# it seems unlikely that we would want our git commit message to be the default, so lets prompt the user
|
||||
echo "Please provide a commit message or press enter"
|
||||
read user_input
|
||||
release_note=$user_input
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="no message provided"
|
||||
fi
|
||||
fi
|
||||
|
||||
git init
|
||||
git add .
|
||||
git commit -am "$release_note"
|
||||
branch_name=$(git rev-parse --abbrev-ref HEAD)
|
||||
git_remote=$(git remote)
|
||||
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
echo "[INFO] Pulling from https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git pull origin $branch_name --ff-only
|
||||
|
||||
echo "[INFO] Pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin $branch_name
|
||||
|
||||
cd $starting_directory
|
||||
Reference in New Issue
Block a user