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
3ffd849c
Commit
3ffd849c
authored
8 years ago
by
Georg Seibt
Browse files
Options
Downloads
Patches
Plain Diff
enable modification of the execution environment options
parent
0117afd0
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/GitWrapper.java
+31
-3
31 additions, 3 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/GitWrapper.java
with
31 additions
and
3 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/GitWrapper.java
+
31
−
3
View file @
3ffd849c
...
...
@@ -43,7 +43,7 @@ public class GitWrapper extends ToolWrapper {
private
static
final
String
GIT_VERSION_C
=
"--version"
;
private
static
final
String
GIT_VERSION_PREFIX
=
"git version"
;
private
static
final
Map
<
String
,
String
>
e
nvironment
;
private
static
final
Map
<
String
,
String
>
defaultE
nvironment
;
private
static
final
List
<
String
>
defaultOptions
;
static
{
...
...
@@ -53,7 +53,7 @@ public class GitWrapper extends ToolWrapper {
env
.
put
(
"LANGUAGE"
,
locale
);
env
.
put
(
"LC_ALL"
,
locale
);
env
.
put
(
"LANG"
,
locale
);
e
nvironment
=
Collections
.
unmodifiableMap
(
env
);
defaultE
nvironment
=
Collections
.
unmodifiableMap
(
env
);
List
<
String
>
defOptions
=
new
ArrayList
<>();
...
...
@@ -347,6 +347,24 @@ public class GitWrapper extends ToolWrapper {
* @return the result of the execution
*/
public
Optional
<
ExecRes
>
exec
(
File
workingDirectory
,
String
firstParameter
,
String
...
parameters
)
{
return
exec
(
workingDirectory
,
null
,
firstParameter
,
parameters
);
}
/**
* Executes '<git command> <firstParameter> <parameters>' and returns the exit code and the output
* of the command. If there is an exception executing the command an empty {@link Optional} will be returned.
*
* @param workingDirectory
* the working directory for the command execution
* @param environment
* additional environment variables for the command execution
* @param firstParameter
* the first git parameter
* @param parameters
* the git parameters
* @return the result of the execution
*/
public
Optional
<
ExecRes
>
exec
(
File
workingDirectory
,
Map
<
String
,
String
>
environment
,
String
firstParameter
,
String
...
parameters
)
{
List
<
String
>
pars
=
new
ArrayList
<>(
defaultOptions
.
size
()
+
((
parameters
!=
null
)
?
parameters
.
length
+
1
:
1
));
pars
.
addAll
(
defaultOptions
);
...
...
@@ -356,6 +374,16 @@ public class GitWrapper extends ToolWrapper {
Collections
.
addAll
(
pars
,
parameters
);
}
return
exec
(
workingDirectory
,
true
,
environment
,
pars
);
Map
<
String
,
String
>
env
;
if
(
environment
!=
null
)
{
env
=
new
HashMap
<>(
defaultEnvironment
.
size
()
+
environment
.
size
());
env
.
putAll
(
environment
);
env
.
putAll
(
defaultEnvironment
);
}
else
{
env
=
GitWrapper
.
defaultEnvironment
;
}
return
exec
(
workingDirectory
,
true
,
env
,
pars
);
}
}
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