Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GitWrapper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Georg Seibt
GitWrapper
Commits
db6601f1
Commit
db6601f1
authored
8 years ago
by
Georg Seibt
Browse files
Options
Downloads
Patches
Plain Diff
document BlameLine
parent
4242a33a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/de/uni_passau/fim/seibt/gitwrapper/repo/BlameLine.java
+87
-2
87 additions, 2 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/BlameLine.java
with
87 additions
and
2 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/BlameLine.java
+
87
−
2
View file @
db6601f1
...
...
@@ -4,18 +4,58 @@ import java.io.File;
import
java.util.Collections
;
import
java.util.Map
;
/**
* A line from a file with the associated 'git blame' information.
*/
@SuppressWarnings
(
"WeakerAccess"
)
public
class
BlameLine
{
/**
* The last commit to change the line.
*/
public
final
Commit
commit
;
/**
* The line number of the line in the original file.
*/
public
final
int
originalLineNumber
;
/**
* The line number of the line in the final file.
*/
public
final
int
finalLineNumber
;
/**
* The file in the commit that the line is attributed to.
*/
public
final
File
file
;
/**
* The actual line from the file.
*/
public
final
String
line
;
/**
* Other (unrecognized) fields from the 'git blame' commit header.
*/
public
final
Map
<
String
,
String
>
otherHeaderFields
;
/**
* Constructs a new {@link BlameLine}.
*
* @param commit
* the last commit to change the line
* @param originalLineNumber
* the line number of the line in the original file
* @param finalLineNumber
* the line number of the line in the final file
* @param file
* the file in the commit that the line is attributed to
* @param line
* the actual line from the file
* @param otherHeaderFields
* other (unrecognized) fields from the 'git blame' commit header
*/
private
BlameLine
(
Commit
commit
,
int
originalLineNumber
,
int
finalLineNumber
,
File
file
,
String
line
,
Map
<
String
,
String
>
otherHeaderFields
)
{
...
...
@@ -27,16 +67,61 @@ public class BlameLine {
this
.
otherHeaderFields
=
otherHeaderFields
;
}
/**
* Constructs a new {@link BlameLine}. This method is to be used when the 'git blame' parser in
* {@link Repository#parseBlameLines(String)} first reads the commit header for a commit.
*
* @param commit
* the last commit to change the line
* @param originalLineNumber
* the line number of the line in the original file
* @param finalLineNumber
* the line number of the line in the final file
* @param file
* the file in the commit that the line is attributed to
* @param line
* the actual line from the file
* @param otherHeaderFields
* other (unrecognized) fields from the 'git blame' commit header
* @return a {@link BlameLine} containing the given header fields
*/
static
BlameLine
firstOccurrence
(
Commit
commit
,
int
originalLineNumber
,
int
finalLineNumber
,
File
file
,
String
line
,
Map
<
String
,
String
>
otherHeaderFields
)
{
Map
<
String
,
String
>
other
=
otherHeaderFields
.
isEmpty
()
?
Collections
.
EMPTY_MAP
:
Collections
.
unmodifiableMap
(
otherHeaderFields
);
Map
<
String
,
String
>
other
;
if
(
otherHeaderFields
.
isEmpty
())
{
other
=
Collections
.
emptyMap
();
}
else
{
other
=
Collections
.
unmodifiableMap
(
otherHeaderFields
);
}
return
new
BlameLine
(
commit
,
originalLineNumber
,
finalLineNumber
,
file
,
line
,
other
);
}
/**
* Constructs a new {@link BlameLine}. This method is to be used when the 'git blame' parser encounters a line
* attributed to a commit whose header was previously read an packaged in a {@link BlameLine}. References to the
* header fields that are not line specific will be taken from {@code firstOccurrence} and stored in the returned
* {@link BlameLine}.
*
* @param firstOccurrence
* the {@link BlameLine} representing the first occurrence of the commit it contains
* @param originalLineNumber
* the line number of the line in the original file
* @param finalLineNumber
* the line number of the line in the final file
* @param line
* the actual line from the file
* @return a {@link BlameLine} containing the given header fields and references to the {@code firstOccurrence}
*/
static
BlameLine
nextOccurrence
(
BlameLine
firstOccurrence
,
int
originalLineNumber
,
int
finalLineNumber
,
String
line
)
{
return
new
BlameLine
(
firstOccurrence
.
commit
,
originalLineNumber
,
finalLineNumber
,
firstOccurrence
.
file
,
line
,
firstOccurrence
.
otherHeaderFields
);
Commit
commit
=
firstOccurrence
.
commit
;
File
file
=
firstOccurrence
.
file
;
Map
<
String
,
String
>
otherHeaderFields
=
firstOccurrence
.
otherHeaderFields
;
return
new
BlameLine
(
commit
,
originalLineNumber
,
finalLineNumber
,
file
,
line
,
otherHeaderFields
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment