Skip to content

Commit f22aa6b

Browse files
committed
Merge pull request hudson2-plugins#28 from kevinsawicki/to-string
Fix embedded quotes in verbose logging string
2 parents b363d64 + c3e3362 commit f22aa6b

2 files changed

Lines changed: 20 additions & 15 deletions

File tree

src/main/java/hudson/plugins/git/Revision.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package hudson.plugins.git;
22

3+
import com.google.common.base.Function;
4+
import com.google.common.base.Joiner;
5+
import com.google.common.collect.Iterables;
6+
37
import java.util.ArrayList;
48
import java.util.Collection;
59

@@ -8,10 +12,10 @@
812
import org.eclipse.jgit.lib.ObjectId;
913

1014
/**
11-
* A Revision is a SHA1 in the object tree, and the collection of branches
12-
* that share this ID. Unlike other SCMs, git can have >1 branches point
13-
* at the _same_ commit.
14-
*
15+
* A Revision is a SHA1 in the object tree, and the collection of branches that
16+
* share this ID. Unlike other SCMs, git can have >1 branches point at the
17+
* _same_ commit.
18+
*
1519
* @author magnayn
1620
*/
1721
@ExportedBean(defaultVisibility = 999)
@@ -63,15 +67,16 @@ public boolean containsBranchName(String name) {
6367
}
6468

6569
public String toString() {
66-
String s = "Revision " + sha1.name() + " (";
67-
for (Branch br : branches) {
68-
s += br.getName() + ", ";
69-
}
70-
if (s.endsWith(", "))
71-
s = s.substring(0, s.length() - 2);
72-
s += ")";
73-
74-
return s;
70+
StringBuilder s = new StringBuilder("Revision " + sha1.name() + " (");
71+
Joiner.on(", ").appendTo(s,
72+
Iterables.transform(branches, new Function<Branch, String>() {
73+
74+
public String apply(Branch from) {
75+
return from.getName();
76+
}
77+
}));
78+
s.append(')');
79+
return s.toString();
7580
}
7681

7782
@Override

src/main/java/hudson/plugins/git/util/DefaultBuildChooser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,15 @@ private Collection<Revision> getAdvancedCandidateRevisions(boolean isPollCall, T
158158
verbose(listener, "After non-tip filtering: {0}", revs);
159159

160160
// 4. Finally, remove any revisions that have already been built.
161-
verbose(listener, "Removing what's already been built: {0}", data.getBuildsByBranchName());
161+
verbose(listener, "Removing what''s already been built: {0}", data.getBuildsByBranchName());
162162
for (Iterator<Revision> i = revs.iterator(); i.hasNext();) {
163163
Revision r = i.next();
164164

165165
if (data.hasBeenBuilt(r.getSha1())) {
166166
i.remove();
167167
}
168168
}
169-
verbose(listener, "After filtering out what's already been built: {0}", revs);
169+
verbose(listener, "After filtering out what''s already been built: {0}", revs);
170170

171171
// if we're trying to run a build (not an SCM poll) and nothing new
172172
// was found then just run the last build again

0 commit comments

Comments
 (0)