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
52527c72
Commit
52527c72
authored
Mar 31, 2017
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Use git.commit.id.abbrev if present" contribution
Closes gh-8781
parent
30b6166b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
14 deletions
+13
-14
GitProperties.java
...ain/java/org/springframework/boot/info/GitProperties.java
+4
-5
GitPropertiesTests.java
...ava/org/springframework/boot/info/GitPropertiesTests.java
+9
-9
No files found.
spring-boot/src/main/java/org/springframework/boot/info/GitProperties.java
View file @
52527c72
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -54,11 +54,10 @@ public class GitProperties extends InfoProperties {
...
@@ -54,11 +54,10 @@ public class GitProperties extends InfoProperties {
* @return the short commit id
* @return the short commit id
*/
*/
public
String
getShortCommitId
()
{
public
String
getShortCommitId
()
{
String
idAbbrev
=
get
(
"commit.id.abbrev"
);
String
shortId
=
get
(
"commit.id.abbrev"
);
if
(
idAbbrev
!=
null
)
{
if
(
shortId
!=
null
)
{
return
idAbbrev
;
return
shortId
;
}
}
String
id
=
getCommitId
();
String
id
=
getCommitId
();
if
(
id
==
null
)
{
if
(
id
==
null
)
{
return
null
;
return
null
;
...
...
spring-boot/src/test/java/org/springframework/boot/info/GitPropertiesTests.java
View file @
52527c72
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -73,6 +73,14 @@ public class GitPropertiesTests {
...
@@ -73,6 +73,14 @@ public class GitPropertiesTests {
assertThat
(
properties
.
get
(
"commit.time"
)).
isEqualTo
(
"2016-03-04 15:22:24"
);
assertThat
(
properties
.
get
(
"commit.time"
)).
isEqualTo
(
"2016-03-04 15:22:24"
);
}
}
@Test
public
void
shortCommitUsedIfPresent
()
{
GitProperties
properties
=
new
GitProperties
(
createProperties
(
"master"
,
"abcdefghijklmno"
,
"abcdefgh"
,
"1457527123"
));
assertThat
(
properties
.
getCommitId
()).
isEqualTo
(
"abcdefghijklmno"
);
assertThat
(
properties
.
getShortCommitId
()).
isEqualTo
(
"abcdefgh"
);
}
@Test
@Test
public
void
shortenCommitIdShorterThan7
()
{
public
void
shortenCommitIdShorterThan7
()
{
GitProperties
properties
=
new
GitProperties
(
GitProperties
properties
=
new
GitProperties
(
...
@@ -89,14 +97,6 @@ public class GitPropertiesTests {
...
@@ -89,14 +97,6 @@ public class GitPropertiesTests {
assertThat
(
properties
.
getShortCommitId
()).
isEqualTo
(
"abcdefg"
);
assertThat
(
properties
.
getShortCommitId
()).
isEqualTo
(
"abcdefg"
);
}
}
@Test
public
void
shortCommitIdCustomLength
()
{
GitProperties
properties
=
new
GitProperties
(
createProperties
(
"master"
,
"abcdefghijklmno"
,
"abcdefgh"
,
"1457527123"
));
assertThat
(
properties
.
getCommitId
()).
isEqualTo
(
"abcdefghijklmno"
);
assertThat
(
properties
.
getShortCommitId
()).
isEqualTo
(
"abcdefgh"
);
}
private
static
Properties
createProperties
(
String
branch
,
String
commitId
,
private
static
Properties
createProperties
(
String
branch
,
String
commitId
,
String
commitIdAbbrev
,
String
commitTime
)
{
String
commitIdAbbrev
,
String
commitTime
)
{
Properties
properties
=
new
Properties
();
Properties
properties
=
new
Properties
();
...
...
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