fix command line, update git_push.sh

This commit is contained in:
wing328 2016-03-11 14:50:03 +08:00
parent 4d023e9b92
commit 3bebbada98
7 changed files with 16 additions and 53 deletions

View File

@ -106,16 +106,16 @@ public class Generate implements Runnable {
@Option(name = {"--library"}, title = "library", description = CodegenConstants.LIBRARY_DESC)
private String library;
@Option(name = {"--git-user-id"}, title = "git user id", description = CodegenConstants.GIT_USER_ID)
@Option(name = {"--git-user-id"}, title = "git user id", description = CodegenConstants.GIT_USER_ID_DESC)
private String gitUserId;
@Option(name = {"--git-repo-id"}, title = "git repo id", description = CodegenConstants.GIT_REPO_ID)
@Option(name = {"--git-repo-id"}, title = "git repo id", description = CodegenConstants.GIT_REPO_ID_DESC)
private String gitRepoId;
@Option(name = {"--release-note"}, title = "release note", description = CodegenConstants.RELEASE_NOTE)
@Option(name = {"--release-note"}, title = "release note", description = CodegenConstants.RELEASE_NOTE_DESC)
private String releaseNote;
@Option(name = {"--release-version"}, title = "release version", description = CodegenConstants.RELEASE_VERSION)
@Option(name = {"--release-version"}, title = "release version", description = CodegenConstants.RELEASE_VERSION_DESC)
private String releaseVersion;
@Override
@ -195,19 +195,19 @@ public class Generate implements Runnable {
configurator.setLibrary(library);
}
if(isNotEmpty(gitUserId)) {
if (isNotEmpty(gitUserId)) {
configurator.setGitUserId(gitUserId);
}
if(isNotEmpty(gitRepoId)) {
if (isNotEmpty(gitRepoId)) {
configurator.setGitRepoId(gitRepoId);
}
if(isNotEmpty(releaseNote)) {
if (isNotEmpty(releaseNote)) {
configurator.setReleaseNote(releaseNote);
}
if(isNotEmpty(releaseVersion)) {
if (isNotEmpty(releaseVersion)) {
configurator.setReleaseVersion(releaseVersion);
}

View File

@ -120,22 +120,6 @@ public class DefaultCodegen {
this.setModelNameSuffix((String) additionalProperties.get(CodegenConstants.MODEL_NAME_SUFFIX));
}
if (StringUtils.isEmpty(this.getGitRepoId()))
this.setGitRepoId("YOUR_GIT_REPO_ID");
additionalProperties.put(CodegenConstants.GIT_REPO_ID, this.getGitRepoId());
if (StringUtils.isEmpty(this.getGitUserId()))
this.setGitUserId("YOUR_GIT_USER_ID");
additionalProperties.put(CodegenConstants.GIT_USER_ID, this.getGitUserId());
if (StringUtils.isEmpty(this.getReleaseNote()))
this.setReleaseNote("Minor update");
additionalProperties.put(CodegenConstants.RELEASE_NOTE, this.getReleaseNote());
if (StringUtils.isEmpty(this.getReleaseVersion()))
this.setReleaseVersion("0.1.0");
additionalProperties.put(CodegenConstants.RELEASE_VERSION, this.getReleaseVersion());
}
// override with any special post-processing for all models

View File

@ -362,6 +362,10 @@ public class CodegenConfigurator {
checkAndSetAdditionalProperty(templateDir, toAbsolutePathStr(templateDir), CodegenConstants.TEMPLATE_DIR);
checkAndSetAdditionalProperty(modelNamePrefix, CodegenConstants.MODEL_NAME_PREFIX);
checkAndSetAdditionalProperty(modelNameSuffix, CodegenConstants.MODEL_NAME_SUFFIX);
checkAndSetAdditionalProperty(gitUserId, CodegenConstants.GIT_USER_ID);
checkAndSetAdditionalProperty(gitRepoId, CodegenConstants.GIT_REPO_ID);
checkAndSetAdditionalProperty(releaseVersion, CodegenConstants.RELEASE_VERSION);
checkAndSetAdditionalProperty(releaseNote, CodegenConstants.RELEASE_NOTE);
handleDynamicProperties(config);

View File

@ -136,7 +136,7 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
supportingFiles.add(new SupportingFile("autodoc.script.mustache", "bin", "autodoc"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("git_push.mustache", "", "git_push.sh"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
}
@Override

View File

@ -1,25 +0,0 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
# Initialize the local directory as a Git repository
git init
# Adds the files in the local repository and stages them for commit.
git add .
# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "{{{releaseNote}}}""
# Sets the new remote
# The fatal error can be igored if the remote was added before
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN is not set. Using the git crediential in your environment."
git remote add origin https://github.com/{{{githUserId}}}/{{{gitRepoId}}}.git
else:
git remote add origin https://{{{gitUserId}}}:${GIT_TOKEN}@github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git
fi
# Pushes (Forces) the changes in the local repository up to the remote repository
git push origin master --force

View File

@ -8,7 +8,7 @@ WWW::SwaggerClient::Role - a Moose role for the Swagger Petstore
Automatically generated by the Perl Swagger Codegen project:
- Build date: 2016-03-10T21:56:51.347+08:00
- Build date: 2016-03-11T14:45:16.064+08:00
- Build package: class io.swagger.codegen.languages.PerlClientCodegen
- Codegen version:

View File

@ -37,7 +37,7 @@ has version_info => ( is => 'ro',
default => sub { {
app_name => 'Swagger Petstore',
app_version => '1.0.0',
generated_date => '2016-03-10T21:56:51.347+08:00',
generated_date => '2016-03-11T14:45:16.064+08:00',
generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen',
} },
documentation => 'Information about the application version and the codegen codebase version'
@ -103,7 +103,7 @@ Automatically generated by the Perl Swagger Codegen project:
=over 4
=item Build date: 2016-03-10T21:56:51.347+08:00
=item Build date: 2016-03-11T14:45:16.064+08:00
=item Build package: class io.swagger.codegen.languages.PerlClientCodegen