Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
4865c23a
Commit
4865c23a
authored
Mar 16, 2021
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.3.x' into 2.4.x
Closes gh-25695
parents
2560f261
bf33e7ef
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
117 additions
and
11 deletions
+117
-11
UpgradeBom.java
...a/org/springframework/boot/build/bom/bomr/UpgradeBom.java
+28
-2
GitHubRepository.java
...ramework/boot/build/bom/bomr/github/GitHubRepository.java
+12
-2
Issue.java
...org/springframework/boot/build/bom/bomr/github/Issue.java
+61
-0
StandardGitHubRepository.java
.../boot/build/bom/bomr/github/StandardGitHubRepository.java
+16
-7
No files found.
buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/UpgradeBom.java
View file @
4865c23a
...
...
@@ -23,6 +23,7 @@ import java.io.Reader;
import
java.nio.file.Path
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Properties
;
...
...
@@ -41,6 +42,7 @@ import org.gradle.api.tasks.options.Option;
import
org.springframework.boot.build.bom.BomExtension
;
import
org.springframework.boot.build.bom.bomr.github.GitHub
;
import
org.springframework.boot.build.bom.bomr.github.GitHubRepository
;
import
org.springframework.boot.build.bom.bomr.github.Issue
;
import
org.springframework.boot.build.bom.bomr.github.Milestone
;
import
org.springframework.util.StringUtils
;
...
...
@@ -83,6 +85,7 @@ public class UpgradeBom extends DefaultTask {
"Unknown label(s): "
+
StringUtils
.
collectionToCommaDelimitedString
(
unknownLabels
));
}
Milestone
milestone
=
determineMilestone
(
repository
);
List
<
Issue
>
existingUpgradeIssues
=
repository
.
findIssues
(
issueLabels
,
milestone
);
List
<
Upgrade
>
upgrades
=
new
InteractiveUpgradeResolver
(
new
MavenMetadataVersionResolver
(
Arrays
.
asList
(
"https://repo1.maven.org/maven2/"
)),
this
.
bom
.
getUpgrade
().
getPolicy
(),
getServices
().
get
(
UserInputHandler
.
class
))
...
...
@@ -92,10 +95,22 @@ public class UpgradeBom extends DefaultTask {
UpgradeApplicator
upgradeApplicator
=
new
UpgradeApplicator
(
buildFile
,
gradleProperties
);
for
(
Upgrade
upgrade
:
upgrades
)
{
String
title
=
"Upgrade to "
+
upgrade
.
getLibrary
().
getName
()
+
" "
+
upgrade
.
getVersion
();
System
.
out
.
println
(
title
);
Issue
existingUpgradeIssue
=
findExistingUpgradeIssue
(
existingUpgradeIssues
,
upgrade
);
if
(
existingUpgradeIssue
!=
null
)
{
System
.
out
.
println
(
title
+
" (supersedes #"
+
existingUpgradeIssue
.
getNumber
()
+
" "
+
existingUpgradeIssue
.
getTitle
()
+
")"
);
}
else
{
System
.
out
.
println
(
title
);
}
try
{
Path
modified
=
upgradeApplicator
.
apply
(
upgrade
);
int
issueNumber
=
repository
.
openIssue
(
title
,
issueLabels
,
milestone
);
int
issueNumber
=
repository
.
openIssue
(
title
,
(
existingUpgradeIssue
!=
null
)
?
"Supersedes #"
+
existingUpgradeIssue
.
getNumber
()
:
""
,
issueLabels
,
milestone
);
if
(
existingUpgradeIssue
!=
null
)
{
existingUpgradeIssue
.
label
(
Arrays
.
asList
(
"type: task"
,
"status: superseded"
));
}
if
(
new
ProcessBuilder
().
command
(
"git"
,
"add"
,
modified
.
toFile
().
getAbsolutePath
()).
start
()
.
waitFor
()
!=
0
)
{
throw
new
IllegalStateException
(
"git add failed"
);
...
...
@@ -114,6 +129,17 @@ public class UpgradeBom extends DefaultTask {
}
}
private
Issue
findExistingUpgradeIssue
(
List
<
Issue
>
existingUpgradeIssues
,
Upgrade
upgrade
)
{
String
toMatch
=
"Upgrade to "
+
upgrade
.
getLibrary
().
getName
();
for
(
Issue
existingUpgradeIssue
:
existingUpgradeIssues
)
{
if
(
existingUpgradeIssue
.
getTitle
().
substring
(
0
,
existingUpgradeIssue
.
getTitle
().
lastIndexOf
(
' '
))
.
equals
(
toMatch
))
{
return
existingUpgradeIssue
;
}
}
return
null
;
}
private
GitHub
createGitHub
()
{
Properties
bomrProperties
=
new
Properties
();
try
(
Reader
reader
=
new
FileReader
(
new
File
(
System
.
getProperty
(
"user.home"
),
".bomr.properties"
)))
{
...
...
buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/github/GitHubRepository.java
View file @
4865c23a
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -29,11 +29,12 @@ public interface GitHubRepository {
* Opens a new issue with the given title. The given {@code labels} will be applied to
* the issue and it will be assigned to the given {@code milestone}.
* @param title the title of the issue
* @param body the body of the issue
* @param labels the labels to apply to the issue
* @param milestone the milestone to assign the issue to
* @return the number of the new issue
*/
int
openIssue
(
String
title
,
List
<
String
>
labels
,
Milestone
milestone
);
int
openIssue
(
String
title
,
String
body
,
List
<
String
>
labels
,
Milestone
milestone
);
/**
* Returns the labels in the repository.
...
...
@@ -47,4 +48,13 @@ public interface GitHubRepository {
*/
List
<
Milestone
>
getMilestones
();
/**
* Finds issues that have the given {@code labels} and are assigned to the given
* {@code milestone}.
* @param labels issue labels
* @param milestone assigned milestone
* @return the matching issues
*/
List
<
Issue
>
findIssues
(
List
<
String
>
labels
,
Milestone
milestone
);
}
buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/github/Issue.java
0 → 100644
View file @
4865c23a
/*
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
build
.
bom
.
bomr
.
github
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
org.springframework.web.client.RestTemplate
;
/**
* Minimal representation of a GitHub issue.
*
* @author Andy Wilkinson
*/
public
class
Issue
{
private
final
RestTemplate
rest
;
private
final
int
number
;
private
final
String
title
;
Issue
(
RestTemplate
rest
,
int
number
,
String
title
)
{
this
.
rest
=
rest
;
this
.
number
=
number
;
this
.
title
=
title
;
}
public
int
getNumber
()
{
return
this
.
number
;
}
public
String
getTitle
()
{
return
this
.
title
;
}
/**
* Labels the issue with the given {@code labels}. Any existing labels are removed.
* @param labels the labels to apply to the issue
*/
public
void
label
(
List
<
String
>
labels
)
{
Map
<
String
,
List
<
String
>>
body
=
Collections
.
singletonMap
(
"labels"
,
labels
);
this
.
rest
.
put
(
"issues/"
+
this
.
number
+
"/labels"
,
body
);
}
}
buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/github/StandardGitHubRepository.java
View file @
4865c23a
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -40,16 +40,17 @@ final class StandardGitHubRepository implements GitHubRepository {
@Override
@SuppressWarnings
(
"rawtypes"
)
public
int
openIssue
(
String
title
,
List
<
String
>
labels
,
Milestone
milestone
)
{
Map
<
String
,
Object
>
b
ody
=
new
HashMap
<>();
b
ody
.
put
(
"title"
,
title
);
public
int
openIssue
(
String
title
,
String
body
,
List
<
String
>
labels
,
Milestone
milestone
)
{
Map
<
String
,
Object
>
requestB
ody
=
new
HashMap
<>();
requestB
ody
.
put
(
"title"
,
title
);
if
(
milestone
!=
null
)
{
b
ody
.
put
(
"milestone"
,
milestone
.
getNumber
());
requestB
ody
.
put
(
"milestone"
,
milestone
.
getNumber
());
}
if
(!
labels
.
isEmpty
())
{
b
ody
.
put
(
"labels"
,
labels
);
requestB
ody
.
put
(
"labels"
,
labels
);
}
ResponseEntity
<
Map
>
response
=
this
.
rest
.
postForEntity
(
"issues"
,
body
,
Map
.
class
);
requestBody
.
put
(
"body"
,
body
);
ResponseEntity
<
Map
>
response
=
this
.
rest
.
postForEntity
(
"issues"
,
requestBody
,
Map
.
class
);
return
(
Integer
)
response
.
getBody
().
get
(
"number"
);
}
...
...
@@ -64,6 +65,14 @@ final class StandardGitHubRepository implements GitHubRepository {
(
milestone
)
->
new
Milestone
((
String
)
milestone
.
get
(
"title"
),
(
Integer
)
milestone
.
get
(
"number"
)));
}
@Override
public
List
<
Issue
>
findIssues
(
List
<
String
>
labels
,
Milestone
milestone
)
{
return
get
(
"issues?per_page=100&state=all&labels="
+
String
.
join
(
","
,
labels
)
+
"&milestone="
+
milestone
.
getNumber
(),
(
issue
)
->
new
Issue
(
this
.
rest
,
(
Integer
)
issue
.
get
(
"number"
),
(
String
)
issue
.
get
(
"title"
)));
}
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
private
<
T
>
List
<
T
>
get
(
String
name
,
Function
<
Map
<
String
,
Object
>,
T
>
mapper
)
{
ResponseEntity
<
List
>
response
=
this
.
rest
.
getForEntity
(
name
,
List
.
class
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment