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
3c348ffb
Commit
3c348ffb
authored
6 years ago
by
Jack MacLauchlan CS2015
Browse files
Options
Downloads
Patches
Plain Diff
can read hash of issues stored
parent
882f74d2
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
src/main/java/command/CommandLs.java
+6
-2
6 additions, 2 deletions
src/main/java/command/CommandLs.java
src/main/java/git/IssueReader.java
+37
-0
37 additions, 0 deletions
src/main/java/git/IssueReader.java
src/main/java/git/IssueRepo.java
+4
-3
4 additions, 3 deletions
src/main/java/git/IssueRepo.java
with
47 additions
and
5 deletions
src/main/java/command/CommandLs.java
+
6
−
2
View file @
3c348ffb
package
command
;
import
git.IssueReader
;
import
issueData.IssueRepository
;
public
class
CommandLs
implements
Command
{
@Override
public
void
execute
()
{
IssueRepository
issueRepository
=
new
IssueRepository
();
issueRepository
.
getIssues
().
forEach
(
System
.
out
::
println
);
// IssueRepository issueRepository = new IssueRepository();
// issueRepository.getIssues().forEach(System.out::println);
IssueReader
issueReader
=
new
IssueReader
();
issueReader
.
walkTree
();
}
}
This diff is collapsed.
Click to expand it.
src/main/java/git/IssueReader.java
+
37
−
0
View file @
3c348ffb
package
git
;
import
issueData.Issue
;
import
org.eclipse.jgit.treewalk.TreeWalk
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
IssueReader
{
private
IssueRepo
repo
;
private
List
<
Issue
>
issues
;
public
IssueReader
()
{
this
.
repo
=
new
IssueRepo
();
this
.
issues
=
new
ArrayList
<>();
}
public
void
walkTree
()
{
try
(
TreeWalk
treeWalk
=
new
TreeWalk
(
repo
.
getRepository
()))
{
treeWalk
.
addTree
(
repo
.
getCurrentCommit
().
getTree
());
treeWalk
.
setRecursive
(
true
);
while
(
treeWalk
.
next
())
{
if
(
issues
.
isEmpty
()
||
!
exists
(
treeWalk
.
getPathString
())){
Issue
issue
=
new
Issue
();
issue
.
setOriginalHash
(
trimPath
(
treeWalk
.
getPathString
()));
issues
.
add
(
issue
);
System
.
out
.
println
(
"create"
);
}
// System.out.println(treeWalk.getPathString());
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
public
boolean
exists
(
String
path
){
for
(
Issue
issue
:
issues
)
{
if
(
issue
.
getOriginalHash
().
equals
(
trimPath
(
path
)))
return
true
;
}
return
false
;
}
public
String
trimPath
(
String
path
){
return
path
.
split
(
"/"
)[
0
];
}
}
This diff is collapsed.
Click to expand it.
src/main/java/git/IssueRepo.java
+
4
−
3
View file @
3c348ffb
...
...
@@ -57,7 +57,6 @@ public class IssueRepo {
commitBuilder
.
setTreeId
(
oi
.
insert
(
Constants
.
OBJ_TREE
,
new
byte
[]{}));
}
//update issues branch ref to point to new commit
ObjectId
newCommit
=
oi
.
insert
(
commitBuilder
);
RefUpdate
update
=
repository
.
updateRef
(
"refs/heads/issues"
);
...
...
@@ -88,7 +87,7 @@ public class IssueRepo {
return
issuesTreeFormatter
;
}
p
rivate
RevCommit
getCurrentCommit
()
throws
IOException
{
p
ublic
RevCommit
getCurrentCommit
()
throws
IOException
{
Ref
issueRef
=
repository
.
findRef
(
"refs/heads/issues"
);
RevCommit
commit
;
...
...
@@ -117,5 +116,7 @@ public class IssueRepo {
}
}
public
Repository
getRepository
()
{
return
repository
;
}
}
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