Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
tor-browser-bundle-testsuite
Commits
472afccb
Unverified
Commit
472afccb
authored
Jul 24, 2014
by
boklm
Browse files
Add TBBTestSuite::BrowserGit;
parent
f980d996
Changes
1
Hide whitespace changes
Inline
Side-by-side
TBBTestSuite/BrowserGit.pm
0 → 100644
View file @
472afccb
package
TBBTestSuite::
BrowserGit
;
use
strict
;
use
FindBin
;
use
TBBTestSuite::
Common
qw(exit_error)
;
use
Cwd
qw(getcwd)
;
use
IO::
CaptureOutput
qw(capture_exec)
;
our
(
@ISA
,
@EXPORT_OK
);
BEGIN
{
require
Exporter
;
@ISA
=
qw(Exporter)
;
@EXPORT_OK
=
qw(git_clone_fetch get_commits_by_branch parent_commit)
;
}
my
$torbrowsergit
=
'
https://git.torproject.org/tor-browser.git
';
my
$geckodevgit
=
'
https://git.mozilla.org/integration/gecko-dev.git
';
our
$clone_dir
=
"
$FindBin
::Bin/clones/tor-browser
";
sub
git_cmd
{
my
$oldcwd
=
getcwd
;
chdir
$clone_dir
||
exit_error
"
Error entering directory
$clone_dir
";
my
@res
=
capture_exec
(
@
_
);
chdir
$oldcwd
;
if
(
!
$res
[
2
])
{
exit_error
'
Error running
'
.
join
('
',
@
_
)
.
"
:
\n
"
.
$res
[
1
];
}
return
@res
;
}
sub
git_cmd_ch
{
my
(
@res
)
=
git_cmd
(
@
_
);
chomp
@res
;
return
@res
;
}
sub
git_clone_fetch
{
mkdir
"
$FindBin
::Bin/clones
"
unless
-
d
"
$FindBin
::Bin/clones
";
if
(
!-
d
$clone_dir
)
{
system
('
git
',
'
clone
',
$torbrowsergit
,
$clone_dir
)
==
0
||
exit_error
"
Error cloning
$torbrowsergit
";
}
git_cmd
('
git
',
'
fetch
',
'
origin
',
'
+refs/heads/*:refs/heads/*
');
my
(
$r
)
=
git_cmd
('
git
',
'
remote
');
git_cmd
('
git
',
'
remote
',
'
add
',
'
gecko-dev
',
$geckodevgit
)
unless
$r
=~
m/^gecko-dev$/m
;
git_cmd
('
git
',
'
fetch
',
'
gecko-dev
');
}
sub
merge_base
{
my
(
$commit_a
,
$commit_b
)
=
@_
;
my
(
$out
)
=
git_cmd_ch
('
git
',
'
merge-base
',
$commit_a
,
$commit_b
);
return
$out
;
}
sub
parent_commits
{
my
(
$c
)
=
@_
;
my
(
$out
)
=
git_cmd_ch
('
git
',
'
show
',
'
-s
',
'
--abbrev=20
',
'
--format=%p
',
$c
);
return
split
('
',
$out
);
}
sub
get_commits
{
my
(
$commit
,
$commit_stop
)
=
@_
;
my
@res
=
(
$commit
);
return
@res
if
$commit
eq
$commit_stop
;
my
(
$parents
)
=
git_cmd_ch
('
git
',
'
show
',
'
-s
',
'
--format=%P
',
$commit
);
foreach
my
$p
(
split
('
',
$parents
))
{
push
@res
,
get_commits
(
$p
,
$commit_stop
);
}
return
@res
;
}
sub
get_commits_by_branch
{
my
(
$tb_branch
,
$esr_branch
)
=
@_
;
my
$base
=
merge_base
(
$tb_branch
,
"
gecko-dev/
$esr_branch
");
my
(
$commit
)
=
git_cmd_ch
('
git
',
'
show
',
'
-s
',
'
--format=%H
',
$tb_branch
);
return
get_commits
(
$commit
,
$base
);
}
1
;
Write
Preview
Supports
Markdown
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