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
8da22502
Commit
8da22502
authored
8 years ago
by
Florian Heck
Browse files
Options
Downloads
Patches
Plain Diff
documentation for status
parent
7afdc3c0
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/Status.java
+26
-4
26 additions, 4 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/Status.java
with
26 additions
and
4 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/Status.java
+
26
−
4
View file @
8da22502
...
...
@@ -8,20 +8,35 @@ import java.util.regex.Pattern;
public
class
Status
{
private
static
final
Pattern
STATUS_ENTRY
=
Pattern
.
compile
(
"(.?.) (?:.*? )?(.*?)\0"
);
public
final
String
hea
d
;
public
final
String
i
d
;
public
final
Map
<
File
,
String
>
changed
;
public
final
Map
<
File
,
String
>
unmerged
;
private
Status
(
String
head
,
Map
<
File
,
String
>
changed
,
Map
<
File
,
String
>
unmerged
)
{
this
.
head
=
head
;
/**
* @param id the commit id
* @param changed a map of changed files and heir status codes
* @param unmerged a map of unmerged files an their status code.
*/
private
Status
(
String
id
,
Map
<
File
,
String
>
changed
,
Map
<
File
,
String
>
unmerged
)
{
this
.
id
=
id
;
this
.
changed
=
Collections
.
unmodifiableMap
(
changed
);
this
.
unmerged
=
Collections
.
unmodifiableMap
(
unmerged
);
}
/**
* Checks, if <code>this</code> represents a clean repository.
*
* @return <code>true</code>, if the repository state is clean and has uncommitted changes.
*/
public
boolean
isClean
()
{
return
changed
.
isEmpty
()
&&
unmerged
.
isEmpty
();
}
/**
* Checks, if <code>this</code> has unmerged files.
*
* @return <code>true</code>, if there are unmerged files
*/
public
boolean
hasConflicts
()
{
return
!
unmerged
.
isEmpty
();
}
...
...
@@ -30,7 +45,7 @@ public class Status {
public
String
toString
()
{
String
out
=
""
;
if
(
isClean
())
{
out
=
"Clean working directory on commit "
+
hea
d
+
"\n"
;
out
=
"Clean working directory on commit "
+
i
d
+
"\n"
;
}
else
{
if
(!
unmerged
.
isEmpty
())
{
out
=
"Unmerged files:"
;
...
...
@@ -47,6 +62,13 @@ public class Status {
return
out
;
}
/**
* Parses the output from git into a new object.
*
* @param repo the repo this status report is from
* @param gitOutput the status report from git
* @return a {@link Status} object, representing the status read from the git output
*/
static
Status
parseStatus
(
Repository
repo
,
String
gitOutput
)
{
Map
<
File
,
String
>
changed
=
new
HashMap
<>();
Map
<
File
,
String
>
unmerged
=
new
HashMap
<>();
...
...
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