6464
6565image_tag=local
6666workspace_name=" /workspace"
67- baseline_generation_config=" baseline_generation_config.yaml"
6867docker_file=" library_generation.Dockerfile"
6968message=" chore: generate libraries at $( date) "
7069
71- git checkout " ${target_branch} "
7270git checkout " ${current_branch} "
73- # if the last commit doesn't contain changes to generation configuration,
74- # do not generate again as the result will be the same.
71+ # if the last commit doesn't contain changes to generation configuration
72+ # or Dockerfile, do not generate again as the result will be the same.
7573change_of_last_commit=" $( git diff-tree --no-commit-id --name-only HEAD~1..HEAD -r) "
7674if [[ ! (" ${change_of_last_commit} " == * " ${generation_config} " * || " ${change_of_last_commit} " == * " ${docker_file} " * ) ]]; then
7775 echo " The last commit doesn't contain any changes to the generation_config.yaml or Dockerfile, skipping the whole generation process." || true
7876 exit 0
7977fi
80- # copy generation configuration from target branch to current branch.
81- git show " ${target_branch} " :" ${generation_config} " > " ${baseline_generation_config} "
82- config_diff=$( diff " ${generation_config} " " ${baseline_generation_config} " || true)
8378
8479generator_version=$( mvn help:evaluate -Dexpression=project.version -q -DforceStdout -pl gapic-generator-java)
8580echo " Local generator version: ${generator_version} "
@@ -99,22 +94,18 @@ docker run \
9994 -v " $( pwd) :${workspace_name} " \
10095 -v " $HOME " /.m2:/home/.m2 \
10196 -e GENERATOR_VERSION=" ${generator_version} " \
102- gcr.io/cloud-devrel-public-resources/java-library-generation:" ${image_tag} " \
103- --baseline-generation-config-path=" ${workspace_name} /${baseline_generation_config} " \
104- --current-generation-config-path=" ${workspace_name} /${generation_config} "
97+ gcr.io/cloud-devrel-public-resources/java-library-generation:" ${image_tag} "
10598
10699# commit the change to the pull request.
107- rm -rdf output googleapis " ${baseline_generation_config} "
100+ rm -rdf output googleapis
108101git add --all -- ' :!pr_description.txt'
109102changed_files=$( git diff --cached --name-only)
110103if [[ " ${changed_files} " == " " ]]; then
111- echo " There is no generated code change with the generation config and Dockerfile change ${config_diff} ."
104+ echo " There is no generated code change."
112105 echo " Skip committing to the pull request."
113106 exit 0
114107fi
115108
116- echo " Configuration diff:"
117- echo " ${config_diff} "
118109git commit -m " ${message} "
119110git push
120111# set pr body if pr_description.txt is generated.
0 commit comments