Skip to content

Commit 7986276

Browse files
authored
Merge pull request #259 from GoogleCloudPlatform/tswast-pull-java-repo-tools
Update to latest java-repo-tools.
2 parents b50e720 + 346295f commit 7986276

File tree

3 files changed

+109
-36
lines changed

3 files changed

+109
-36
lines changed

java-repo-tools/README.md

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,21 @@ git remote add java-repo-tools [email protected]:GoogleCloudPlatform/java-repo-tool
2727
git fetch java-repo-tools master
2828
```
2929

30-
To make it easier to push changes back upstream, create a new branch.
31-
32-
```
33-
git checkout -b java-repo-tools java-repo-tools/master
34-
```
35-
3630
We can then go back to the `my-java-samples` code and prepare a Pull Request to
37-
add the `java-repo-tools` code in a subtree.
38-
39-
```
40-
git checkout master
41-
# Making a new branch ia optional, but recommended to send a pull request to
42-
# start using java-repo-tools.
43-
git checkout -b use-java-repo-tools
44-
```
45-
46-
So that we can pull future updates from the `java-repo-tools` repository, we
47-
merge histories. This way we won't get unnecessary conflicts when pulling changes
48-
in.
31+
add the `java-repo-tools` code in a subtree. Making a new branch is optional, but
32+
recommended so that you can more easily send a pull request to start using
33+
`java-repo-tools`.
4934

5035
```
51-
git merge -s ours --no-commit java-repo-tools/master
36+
git checkout -b use-java-repo-tools origin/master
5237
```
5338

54-
Finally, read the `java-repo-tools` into a subtree.
39+
Finally, read the `java-repo-tools` into a subtree. So that you can pull future
40+
updates from the `java-repo-tools` repository, this command will merge histories.
41+
This way prevents unnecessary conflicts when pulling changes in.
5542

5643
```
57-
git read-tree --prefix=java-repo-tools/ -u java-repo-tools
44+
git subtree add --prefix=java-repo-tools java-repo-tools master
5845
```
5946

6047
Now all the content of `java-repo-tools` will be in the `java-repo-tools/`
@@ -143,22 +130,14 @@ Pull Request as you would in the normal flow.
143130
What if you make changes in your repository and now want to push them upstream?
144131

145132
Assuming you just commited changes in the `java-repo-tools/` directory of your
146-
`my-main-branch`, to merge the changes into the local `java-repo-tools` branch,
147-
we need to cherry pick this commit using the subtree strategy. It will ignore
148-
any changes to file not in the `java-repo-tools/` directory.
149-
150-
```
151-
git checkout java-repo-tools
152-
git cherry-pick -x --strategy=subtree my-main-branch
153-
```
154-
155-
After you have committed all the changes you want to your `java-repo-tools`
156-
branch, you can push to the upstream `java-repo-tools` repository with the
157-
following command. (Replace `name-for-remote-branch` with the name you'd like to
158-
give the branch on the `java-repo-tools` repository.)
133+
`my-main-branch`, to split the `java-repo-tools` changes into their own branch.
134+
The first time using the `subtree` command, we may need to use the `--rejoin`
135+
argument.
159136

160137
```
161-
git push java-repo-tools java-repo-tools:name-for-remote-branch
138+
git subtree split --prefix=java-repo-tools -b ${USER}-push-java-repo-tools
139+
git checkout ${USER}-push-java-repo-tools
140+
git push java-repo-tools ${USER}-push-java-repo-tools
162141
```
163142

164143
Then, you can send a pull request to the `java-repo-tools` repository.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2016 Google Inc. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Usage:
17+
# test-localhost.sh deployment-type path/to/project -- [maven arguments]
18+
#
19+
# This script runs a localhost server Maven plugin and verifies that a request
20+
# to http://localhost:8080/ does not return an error code.
21+
22+
print_usage () {
23+
echo "Usage:" >&2
24+
echo " $0 server-type path/to/project [-- maven arguments]" >&2
25+
echo >&2
26+
echo "server-type can be any of the following:" >&2
27+
echo " appengine" >&2
28+
echo " jetty" >&2
29+
echo " spring-boot" >&2
30+
}
31+
32+
if [[ -z "$1" ]]; then
33+
echo "Missing server-type parameter." >&2
34+
print_usage
35+
exit 1
36+
fi
37+
case $1 in
38+
appengine)
39+
mvn_plugin="appengine:devserver"
40+
server_started_message="localhost:8080"
41+
;;
42+
jetty)
43+
mvn_plugin="jetty:run-exploded"
44+
server_started_message="Started Jetty Server"
45+
;;
46+
spring-boot)
47+
mvn_plugin="spring-boot:run"
48+
server_started_message="Tomcat started on port(s): 8080 (http)"
49+
;;
50+
*)
51+
print_usage
52+
exit 1
53+
;;
54+
esac
55+
56+
if [[ -z "$2" ]]; then
57+
echo "Missing directory parameter." >&2
58+
print_usage
59+
exit 1
60+
fi
61+
code_path=$2
62+
63+
mvn_command="mvn --batch-mode clean ${mvn_plugin} -DskipTests"
64+
if [[ "$3" == "--" ]]; then
65+
shift 3
66+
for mvn_arg in "${@}"; do
67+
mvn_command="${mvn_command} ${mvn_arg}"
68+
done
69+
elif [[ -n "$3" ]]; then
70+
echo "Got unexpected third argument" >&2
71+
print_usage
72+
exit 1
73+
fi
74+
75+
set -e
76+
set -x
77+
78+
(
79+
cd "$code_path"
80+
expect -c "
81+
spawn ${mvn_command}
82+
set timeout 600
83+
expect \"${server_started_message}\"
84+
"'sleep 10
85+
spawn curl --silent --output /dev/stderr --write-out "%{http_code}" http://localhost:8080/
86+
expect {
87+
"200" {
88+
exit
89+
}
90+
}
91+
exit 1
92+
'
93+
)
94+

travis.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ devserver_tests=(
3333
appengine/datastore/indexes-perfect
3434
)
3535
for testdir in ${devserver_tests[@]} ; do
36-
./java-repo-tools/test-devserver.sh "${testdir}"
36+
./java-repo-tools/scripts/test-localhost.sh appengine "${testdir}"
3737
done
3838

0 commit comments

Comments
 (0)