Toggle navigation
Toggle navigation
This project
Loading...
Sign in
노현종
/
2018-1-Capstone1-VulnNotti
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Kiok Ahn
2018-04-18 16:11:00 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a64723d864b5f112c2d3936e88ae7250053514cb
a64723d8
1 parent
3c5ea9e0
DownloaderGithub
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
1 deletions
Vulnerablity_DB/DownloaderGithubClone/Program.cs
Vulnerablity_DB/DownloaderGithubClone/Program.cs
View file @
a64723d
...
...
@@ -6,11 +6,54 @@ using System.Threading.Tasks;
namespace
DownloaderGithubClone
{
using
LibGit2Sharp
;
using
System.Text.RegularExpressions
;
class
Program
{
static
void
Main
(
string
[]
args
)
{
Console
.
WriteLine
(
"A"
);
Console
.
Write
(
"Git Repository URL을 입력하세요 : "
);
string
url
=
Console
.
ReadLine
();
//https://github.com/django/django.git
string
pattern
=
@"https://github.com/(?<ProjectName>\w+)/\w+\.git"
;
var
match
=
Regex
.
Match
(
url
,
pattern
);
if
(!
match
.
Success
)
{
Console
.
WriteLine
(
$
"패턴이 맞지 않습니다. Pattern : {pattern}"
);
return
;
}
string
prName
=
match
.
Groups
[
"ProjectName"
].
Value
;
Console
.
WriteLine
(
prName
);
string
clone
=
Repository
.
Clone
(
url
,
$
@"c:\VulnPy\{prName}"
,
new
CloneOptions
{
OnTransferProgress
=
TransferProgress
,
OnCheckoutProgress
=
CheckoutProcess
});
Console
.
WriteLine
(
clone
);
}
/// <summary>
/// Clone 콜백 함수
/// </summary>
/// <param name="progress"></param>
/// <returns></returns>
public
static
bool
TransferProgress
(
TransferProgress
progress
)
{
int
totalBytes
=
progress
.
TotalObjects
;
int
receivedBytes
=
progress
.
ReceivedObjects
;
long
receivedTotal
=
progress
.
ReceivedBytes
;
double
received
=
progress
.
ReceivedBytes
/
1000000
;
double
percent
=
((
double
)
receivedBytes
/
(
double
)
totalBytes
)
*
10
;
Console
.
WriteLine
(
$
"진행률: {percent.ToString("
P2
")}, 남은 파일: {receivedBytes} of {totalBytes}"
);
//, 받은 용량: {received.ToString()}MB");
Console
.
ForegroundColor
=
ConsoleColor
.
DarkGreen
;
return
true
;
}
public
static
void
CheckoutProcess
(
string
path
,
int
completedSteps
,
int
totalSteps
)
{
Console
.
WriteLine
(
$
"{completedSteps}, {totalSteps}, {path}"
);
}
}
}
...
...
Please
register
or
login
to post a comment