Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
ddit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Jack MacLauchlan CS2015
ddit
Commits
d2fe3d8f
Commit
d2fe3d8f
authored
6 years ago
by
Jack MacLauchlan CS2015
Browse files
Options
Downloads
Patches
Plain Diff
reset point before json only in treebuildeer
parent
e32073c3
No related branches found
No related tags found
1 merge request
!2
Commit tree
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
questions
+3
-1
3 additions, 1 deletion
questions
src/main/java/git/IssueTreeBuilder.java
+27
-31
27 additions, 31 deletions
src/main/java/git/IssueTreeBuilder.java
src/main/java/issueData/Issue.java
+30
-0
30 additions, 0 deletions
src/main/java/issueData/Issue.java
with
60 additions
and
32 deletions
questions
+
3
−
1
View file @
d2fe3d8f
...
...
@@ -10,4 +10,6 @@ when github central server gets pushed send emails, subscribers get emailed, pos
edit time on merge
truncate the input
\ No newline at end of file
truncate the input
filter comments by time
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/git/IssueTreeBuilder.java
+
27
−
31
View file @
d2fe3d8f
package
git
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
issueData.Comment
;
import
issueData.Issue
;
import
org.eclipse.jgit.lib.*
;
import
java.io.IOException
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Set
;
class
IssueTreeBuilder
{
private
final
ObjectInserter
oi
;
private
ObjectMapper
mapper
=
new
ObjectMapper
();
IssueTreeBuilder
(
Repository
repository
)
{
this
.
oi
=
new
ObjectInserter
(
repository
);
}
ObjectId
buildIssueTree
(
Issue
issue
)
throws
IOException
{
TreeFormatter
issueTreeFormatter
=
new
TreeFormatter
();
ObjectId
title
=
oi
.
insert
(
Constants
.
OBJ_BLOB
,
issue
.
getTitle
().
getBytes
());
ObjectId
description
=
oi
.
insert
(
Constants
.
OBJ_BLOB
,
issue
.
getDescription
().
getBytes
());
ObjectId
creator
=
oi
.
insert
(
Constants
.
OBJ_BLOB
,
(
issue
.
getCreator
().
name
+
"\n"
+
issue
.
getCreator
().
email
).
getBytes
());
ObjectId
status
=
oi
.
insert
(
Constants
.
OBJ_BLOB
,
String
.
valueOf
(
issue
.
isOpen
()).
getBytes
());
ObjectId
creationTime
=
oi
.
insert
(
Constants
.
OBJ_BLOB
,
String
.
valueOf
(
issue
.
getCreationTime
()).
getBytes
());
ObjectId
editTime
=
oi
.
insert
(
Constants
.
OBJ_BLOB
,
String
.
valueOf
(
issue
.
getEdited
()).
getBytes
());
ObjectId
tags
=
oi
.
insert
(
Constants
.
OBJ_BLOB
,
buildTagString
(
issue
.
getTags
()).
getBytes
());
byte
[]
titleJson
=
mapper
.
writeValueAsBytes
(
issue
.
getTitle
());
byte
[]
descriptionJson
=
mapper
.
writeValueAsBytes
(
issue
.
getDescription
());
byte
[]
creatorJson
=
mapper
.
writeValueAsBytes
(
issue
.
getCreator
());
byte
[]
statusJson
=
mapper
.
writeValueAsBytes
(
issue
.
isOpen
());
byte
[]
creationTimeJson
=
mapper
.
writeValueAsBytes
(
issue
.
getCreationTime
());
byte
[]
editTimeJson
=
mapper
.
writeValueAsBytes
(
issue
.
getEdited
());
byte
[]
tagsJsonBytes
=
mapper
.
writeValueAsBytes
(
issue
.
getTags
());
ObjectId
title
=
oi
.
insert
(
Constants
.
OBJ_BLOB
,
titleJson
);
ObjectId
description
=
oi
.
insert
(
Constants
.
OBJ_BLOB
,
descriptionJson
);
ObjectId
creator
=
oi
.
insert
(
Constants
.
OBJ_BLOB
,
creatorJson
);
ObjectId
status
=
oi
.
insert
(
Constants
.
OBJ_BLOB
,
statusJson
);
ObjectId
creationTime
=
oi
.
insert
(
Constants
.
OBJ_BLOB
,
creationTimeJson
);
ObjectId
editTime
=
oi
.
insert
(
Constants
.
OBJ_BLOB
,
editTimeJson
);
ObjectId
tags
=
oi
.
insert
(
Constants
.
OBJ_BLOB
,
tagsJsonBytes
);
ObjectId
comments
=
buildCommentTree
(
issue
.
getComments
());
...
...
@@ -48,9 +57,14 @@ class IssueTreeBuilder {
for
(
Comment
comment
:
comments
)
{
TreeFormatter
commentTreeFormatter
=
new
TreeFormatter
();
ObjectId
author
=
oi
.
insert
(
Constants
.
OBJ_BLOB
,
(
comment
.
getAuthor
().
name
+
"\n"
+
comment
.
getAuthor
().
name
).
getBytes
());
ObjectId
message
=
oi
.
insert
(
Constants
.
OBJ_BLOB
,
comment
.
getMessage
().
getBytes
());
ObjectId
commentTime
=
oi
.
insert
(
Constants
.
OBJ_BLOB
,
String
.
valueOf
(
comment
.
getCreationTime
()).
getBytes
());
byte
[]
authorJson
=
mapper
.
writeValueAsBytes
(
comment
.
getAuthor
());
byte
[]
messageJson
=
mapper
.
writeValueAsBytes
(
comment
.
getMessage
());
byte
[]
commentTimeJson
=
mapper
.
writeValueAsBytes
(
comment
.
getCreationTime
());
ObjectId
author
=
oi
.
insert
(
Constants
.
OBJ_BLOB
,
authorJson
);
ObjectId
message
=
oi
.
insert
(
Constants
.
OBJ_BLOB
,
messageJson
);
ObjectId
commentTime
=
oi
.
insert
(
Constants
.
OBJ_BLOB
,
commentTimeJson
);
commentTreeFormatter
.
append
(
"author"
,
FileMode
.
REGULAR_FILE
,
author
);
commentTreeFormatter
.
append
(
"commentTime"
,
FileMode
.
REGULAR_FILE
,
commentTime
);
...
...
@@ -64,23 +78,5 @@ class IssueTreeBuilder {
return
oi
.
insert
(
Constants
.
OBJ_TREE
,
allCommentTreeFormatter
.
toByteArray
());
}
private
String
buildTagString
(
Set
<
String
>
tags
)
{
StringBuilder
stringBuilder
=
new
StringBuilder
();
Iterator
<
String
>
iterator
=
tags
.
iterator
();
if
(!
iterator
.
hasNext
())
{
return
""
;
}
for
(;
;
)
{
stringBuilder
.
append
(
iterator
.
next
());
if
(!
iterator
.
hasNext
())
{
return
stringBuilder
.
toString
();
}
stringBuilder
.
append
(
", "
);
}
}
}
This diff is collapsed.
Click to expand it.
src/main/java/issueData/Issue.java
+
30
−
0
View file @
d2fe3d8f
...
...
@@ -8,6 +8,8 @@ public class Issue {
private
final
Set
<
String
>
tags
;
private
final
List
<
Comment
>
comments
;
private
List
<
User
>
assignees
;
private
List
<
User
>
watchers
;
private
String
title
;
private
String
description
;
private
User
creator
;
...
...
@@ -26,11 +28,15 @@ public class Issue {
this
.
originalHash
=
DigestUtils
.
sha256Hex
(
title
+
description
+
creationTime
);
this
.
comments
=
new
ArrayList
<>();
this
.
tags
=
new
HashSet
<>();
this
.
assignees
=
new
ArrayList
<>();
this
.
watchers
=
new
ArrayList
<>();
}
public
Issue
()
{
comments
=
new
ArrayList
<>();
tags
=
new
HashSet
<>();
assignees
=
new
ArrayList
<>();
watchers
=
new
ArrayList
<>();
}
public
void
edited
()
{
...
...
@@ -69,6 +75,30 @@ public class Issue {
return
comments
;
}
public
void
addWatcher
(
User
user
)
{
watchers
.
add
(
user
);
}
public
List
<
User
>
getWatchers
(){
return
watchers
;
}
public
void
removeWatcher
(
User
user
){
watchers
.
remove
(
user
);
}
public
void
addAssignee
(
User
user
)
{
assignees
.
add
(
user
);
}
public
List
<
User
>
getAssignees
(){
return
assignees
;
}
public
void
removeAssignee
(
User
user
){
assignees
.
remove
(
user
);
}
public
void
addTag
(
String
tag
)
{
List
<
String
>
strings
=
Arrays
.
asList
(
tag
.
split
(
"\\s*,\\s*"
));
strings
.
forEach
(
t
->
{
...
...
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