Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
B
biotools-git-populous
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
INB
ELIXIR
tools-platform
biotools-git-populous
Commits
d9c458d2
Commit
d9c458d2
authored
Oct 31, 2019
by
redmitry@list.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add parameters
parent
6142ea9a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
9 deletions
+23
-9
src/main/java/es/bsc/inb/elixir/biotools/git/populous/Main.java
...in/java/es/bsc/inb/elixir/biotools/git/populous/Main.java
+23
-9
No files found.
src/main/java/es/bsc/inb/elixir/biotools/git/populous/Main.java
View file @
d9c458d2
...
...
@@ -55,14 +55,15 @@ import org.eclipse.jgit.util.SystemReader;
public
class
Main
{
private
final
static
String
HELP
=
"java -jar biotools-populouse.jar -g -u -p [-b] [--path]\n\n"
+
"java -jar biotools-populouse.jar -g -u -p [-b] [--path]
[--dirs]
\n\n"
+
"parameters:\n\n"
+
"-h (--help) - this help message\n"
+
"-g (--git) - git endpoint\n"
+
"-u (--user) 'username' - github username\n"
+
"-p (--password) 'password' - github pasword\n"
+
"-b (--branch) - git remote branch ['origin/master']\n"
+
"--path - git path to put files ['/']\n\n"
+
"--path - git path to put files ['/']\n"
+
"--dirs - if present, put each tool into its own directory \n\n"
+
"example: >java -jar biotools-populous.jar -g https://github.com/xyz.git --path /biotools -u redmitry -p xyz\n"
;
public
final
static
String
BRANCH
=
"origin/master"
;
...
...
@@ -83,6 +84,8 @@ public class Main {
}
final
List
<
String
>
path
=
params
.
get
(
"--path"
);
final
List
<
String
>
suffix
=
params
.
get
(
"--suffix"
);
final
String
sfx
=
suffix
==
null
||
suffix
.
isEmpty
()
?
".opeb.json"
:
suffix
.
get
(
0
);
List
<
String
>
user
=
params
.
get
(
"-u"
);
if
(
user
==
null
)
{
...
...
@@ -108,12 +111,13 @@ public class Main {
final
String
b
=
branch
==
null
||
branch
.
isEmpty
()
?
null
:
branch
.
get
(
0
);
process
(
g
,
b
!=
null
?
b
:
BRANCH
,
path
==
null
||
path
.
isEmpty
()
?
"/"
:
path
.
get
(
0
),
u
,
p
);
path
==
null
||
path
.
isEmpty
()
?
"/"
:
path
.
get
(
0
),
params
.
get
(
"--dirs"
)
!=
null
,
sfx
,
u
,
p
);
}
}
private
static
void
process
(
final
String
endpoint
,
final
String
branch
,
final
String
path
,
final
String
user
,
final
String
password
)
{
final
boolean
dirs
,
final
String
suffix
,
final
String
user
,
final
String
password
)
{
final
int
idx
=
branch
.
lastIndexOf
(
'/'
);
final
String
local
=
idx
<
0
?
branch
:
branch
.
substring
(
idx
+
1
);
...
...
@@ -126,7 +130,7 @@ public class Main {
.
build
();
final
FileSystem
fs
=
Jimfs
.
newFileSystem
(
config
);
final
Path
root
=
fs
.
getPath
(
path
);
final
Path
root
=
fs
.
getPath
(
"/"
);
try
(
Git
git
=
Git
.
cloneRepository
()
.
setURI
(
endpoint
)
...
...
@@ -144,10 +148,18 @@ public class Main {
final
Tool
tool
=
BiotoolsConverter
.
convert
(
jtool
);
final
String
_id
=
tool
.
getSummary
().
getToolID
().
trim
();
final
String
_id
=
tool
.
getSummary
().
getToolID
().
trim
()
.
toLowerCase
()
;
final
String
file_name
=
_id
+
".json"
;
final
Path
file_path
=
root
.
resolve
(
file_name
);
final
Path
dir
=
dirs
?
root
.
resolve
(
path
).
resolve
(
_id
)
:
root
.
resolve
(
path
);
if
(!
Files
.
exists
(
dir
))
{
try
{
Files
.
createDirectories
(
dir
);
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
Main
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
"can't create dir: "
+
dir
,
ex
.
getMessage
());
}
}
final
Path
file_path
=
dir
.
resolve
(
_id
+
suffix
);
try
(
Writer
writer
=
Files
.
newBufferedWriter
(
file_path
))
{
jsonb
.
toJson
(
tool
,
writer
);
...
...
@@ -155,7 +167,7 @@ public class Main {
Logger
.
getLogger
(
Main
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
git
.
add
().
addFilepattern
(
"."
).
call
();
git
.
commit
().
setMessage
(
"biotools commit "
+
Instant
.
now
()).
call
();
git
.
push
().
setRemote
(
branch
).
setCredentialsProvider
(
...
...
@@ -179,6 +191,8 @@ public class Main {
case
"-b"
:
case
"--branch"
:
case
"--path"
:
case
"--dirs"
:
case
"--suffix"
:
case
"-u"
:
case
"--user"
:
case
"-p"
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment