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
4242a33a
Commit
4242a33a
authored
8 years ago
by
Florian Heck
Browse files
Options
Downloads
Patches
Plain Diff
changed status to contain path to changed/unmerged files
parent
0369df0b
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
+13
-10
13 additions, 10 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/Status.java
with
13 additions
and
10 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/Status.java
+
13
−
10
View file @
4242a33a
package
de.uni_passau.fim.seibt.gitwrapper.repo
;
package
de.uni_passau.fim.seibt.gitwrapper.repo
;
import
java.io.File
;
import
java.nio.file.Path
;
import
java.util.*
;
import
java.nio.file.Paths
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
...
@@ -9,15 +12,15 @@ public class Status {
...
@@ -9,15 +12,15 @@ public class Status {
private
static
final
Pattern
STATUS_ENTRY
=
Pattern
.
compile
(
"(.?.) (?:.*? )?(.*?)\0"
);
private
static
final
Pattern
STATUS_ENTRY
=
Pattern
.
compile
(
"(.?.) (?:.*? )?(.*?)\0"
);
public
final
String
id
;
public
final
String
id
;
public
final
Map
<
File
,
String
>
changed
;
public
final
Map
<
Path
,
String
>
changed
;
public
final
Map
<
File
,
String
>
unmerged
;
public
final
Map
<
Path
,
String
>
unmerged
;
/**
/**
* @param id the commit id
* @param id the commit id
* @param changed a map of changed files and heir status codes
* @param changed a map of changed files and heir status codes
* @param unmerged a map of unmerged files an their status code.
* @param unmerged a map of unmerged files an their status code.
*/
*/
private
Status
(
String
id
,
Map
<
File
,
String
>
changed
,
Map
<
File
,
String
>
unmerged
)
{
private
Status
(
String
id
,
Map
<
Path
,
String
>
changed
,
Map
<
Path
,
String
>
unmerged
)
{
this
.
id
=
id
;
this
.
id
=
id
;
this
.
changed
=
Collections
.
unmodifiableMap
(
changed
);
this
.
changed
=
Collections
.
unmodifiableMap
(
changed
);
this
.
unmerged
=
Collections
.
unmodifiableMap
(
unmerged
);
this
.
unmerged
=
Collections
.
unmodifiableMap
(
unmerged
);
...
@@ -49,12 +52,12 @@ public class Status {
...
@@ -49,12 +52,12 @@ public class Status {
}
else
{
}
else
{
if
(!
unmerged
.
isEmpty
())
{
if
(!
unmerged
.
isEmpty
())
{
out
=
"Unmerged files:"
;
out
=
"Unmerged files:"
;
out
+=
unmerged
.
keySet
().
stream
().
map
(
File:
:
getPath
).
reduce
(
""
,
(
list
,
file
)
->
String
.
join
(
"\n"
,
list
,
file
));
out
+=
unmerged
.
keySet
().
stream
().
map
(
Path:
:
toString
).
reduce
(
""
,
(
list
,
file
)
->
String
.
join
(
"\n"
,
list
,
file
));
out
+=
"\n"
;
out
+=
"\n"
;
}
}
if
(!
changed
.
isEmpty
())
{
if
(!
changed
.
isEmpty
())
{
out
+=
"Changed files:"
;
out
+=
"Changed files:"
;
out
+=
changed
.
keySet
().
stream
().
map
(
File:
:
getPath
).
reduce
(
""
,
(
list
,
file
)
->
String
.
join
(
"\n"
,
list
,
file
));
out
+=
changed
.
keySet
().
stream
().
map
(
Path:
:
toString
).
reduce
(
""
,
(
list
,
file
)
->
String
.
join
(
"\n"
,
list
,
file
));
out
+=
"\n"
;
out
+=
"\n"
;
}
}
}
}
...
@@ -70,12 +73,12 @@ public class Status {
...
@@ -70,12 +73,12 @@ public class Status {
* @return a {@link Status} object, representing the status read from the git output
* @return a {@link Status} object, representing the status read from the git output
*/
*/
static
Status
parseStatus
(
Repository
repo
,
String
gitOutput
)
{
static
Status
parseStatus
(
Repository
repo
,
String
gitOutput
)
{
Map
<
File
,
String
>
changed
=
new
HashMap
<>();
Map
<
Path
,
String
>
changed
=
new
HashMap
<>();
Map
<
File
,
String
>
unmerged
=
new
HashMap
<>();
Map
<
Path
,
String
>
unmerged
=
new
HashMap
<>();
Matcher
matcher
=
STATUS_ENTRY
.
matcher
(
gitOutput
);
Matcher
matcher
=
STATUS_ENTRY
.
matcher
(
gitOutput
);
while
(
matcher
.
find
())
{
while
(
matcher
.
find
())
{
// used new path, if file was moved
// used new path, if file was moved
File
file
=
new
File
(
matcher
.
group
(
2
));
Path
file
=
Paths
.
get
(
matcher
.
group
(
2
));
String
code
=
matcher
.
group
(
1
).
toUpperCase
();
String
code
=
matcher
.
group
(
1
).
toUpperCase
();
if
(
code
.
contains
(
"U"
))
{
if
(
code
.
contains
(
"U"
))
{
unmerged
.
put
(
file
,
code
);
unmerged
.
put
(
file
,
code
);
...
...
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