From 3bebbada98234b58934804fa58f538170d991b69 Mon Sep 17 00:00:00 2001 From: wing328 Date: Fri, 11 Mar 2016 14:50:03 +0800 Subject: [PATCH] fix command line, update git_push.sh --- .../java/io/swagger/codegen/cmd/Generate.java | 16 ++++++------ .../io/swagger/codegen/DefaultCodegen.java | 16 ------------ .../codegen/config/CodegenConfigurator.java | 4 +++ .../codegen/languages/PerlClientCodegen.java | 2 +- .../src/main/resources/perl/git_push.sh | 25 ------------------- samples/client/petstore/perl/README.md | 2 +- .../perl/lib/WWW/SwaggerClient/Role.pm | 4 +-- 7 files changed, 16 insertions(+), 53 deletions(-) delete mode 100755 modules/swagger-codegen/src/main/resources/perl/git_push.sh diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java index 3a2d6256c5..50ca6066d8 100644 --- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java +++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java @@ -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); } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index 77a2d1e5d2..0f6f02f045 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -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 diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/config/CodegenConfigurator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/config/CodegenConfigurator.java index 1312d530b8..f228e9d30c 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/config/CodegenConfigurator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/config/CodegenConfigurator.java @@ -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); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java index 82cdd2f881..95fdffa55c 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java @@ -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 diff --git a/modules/swagger-codegen/src/main/resources/perl/git_push.sh b/modules/swagger-codegen/src/main/resources/perl/git_push.sh deleted file mode 100755 index 47842214dd..0000000000 --- a/modules/swagger-codegen/src/main/resources/perl/git_push.sh +++ /dev/null @@ -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 - diff --git a/samples/client/petstore/perl/README.md b/samples/client/petstore/perl/README.md index 1903bd4803..4696fe28ea 100644 --- a/samples/client/petstore/perl/README.md +++ b/samples/client/petstore/perl/README.md @@ -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: diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm index d06e0c22db..24109c491c 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm @@ -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