Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor Browser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Applications
Tor Browser
Commits
108bab6e
Verified
Commit
108bab6e
authored
May 31, 2023
by
henry
Committed by
Pier Angelo Vendrame
Aug 21, 2023
Browse files
Options
Downloads
Patches
Plain Diff
Bug 41803: Add some developer tools for working on tor-browser.
parent
4a8da4f3
Loading
Loading
1 merge request
!734
Bug 42030: Rebased 13.0 alpha onto Firefox 115.2.0esr
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tools/torbrowser/git-rebase-fixup-preprocessor
+93
-0
93 additions, 0 deletions
tools/torbrowser/git-rebase-fixup-preprocessor
tools/torbrowser/tb-dev
+715
-0
715 additions, 0 deletions
tools/torbrowser/tb-dev
with
808 additions
and
0 deletions
tools/torbrowser/git-rebase-fixup-preprocessor
0 → 100755
+
93
−
0
View file @
108bab6e
#!/usr/bin/python
"""
Pre-process a git todo file before passing it on to an editor.
"""
import
sys
import
os
import
subprocess
import
re
EDITOR_ENV_NAME
=
"
GIT_REBASE_FIXUP_PREPROCESSOR_USER_EDITOR
"
try
:
editor
=
os
.
environ
[
EDITOR_ENV_NAME
]
except
KeyError
:
print
(
f
"
Missing
{
EDITOR_ENV_NAME
}
in environment
"
,
file
=
sys
.
stderr
)
exit
(
1
)
if
len
(
sys
.
argv
)
<
2
:
print
(
"
Missing filename argument
"
,
file
=
sys
.
stderr
)
exit
(
1
)
filename
=
sys
.
argv
[
1
]
class
TodoLine
:
"""
Represents a line in the git todo file.
"""
_PICK_REGEX
=
re
.
compile
(
r
"
^pick [a-f0-9]+ (?P<fixups>(fixup! )*)(?P<title>.*)
"
)
def
__init__
(
self
,
line
):
"""
Create a new line with the given text content.
"""
self
.
_line
=
line
self
.
_make_fixup
=
False
match
=
self
.
_PICK_REGEX
.
match
(
line
)
if
match
:
self
.
_is_pick
=
True
self
.
_num_fixups
=
len
(
match
.
group
(
"
fixups
"
))
/
len
(
"
fixup!
"
)
self
.
_title
=
match
.
group
(
"
title
"
)
else
:
self
.
_is_pick
=
False
self
.
_num_fixups
=
False
self
.
_title
=
None
def
add_to_list_try_fixup
(
self
,
existing_lines
):
"""
Add the TodoLine to the given list of other TodoLine, trying to fix up
one of the existing lines.
"""
if
not
self
.
_num_fixups
:
# Not a fixup line.
existing_lines
.
append
(
self
)
return
# Search from the end of the list upwards.
for
index
in
reversed
(
range
(
len
(
existing_lines
))):
other
=
existing_lines
[
index
]
if
(
other
.
_is_pick
and
self
.
_num_fixups
==
other
.
_num_fixups
+
1
and
other
.
_title
==
self
.
_title
):
self
.
_make_fixup
=
True
existing_lines
.
insert
(
index
+
1
,
self
)
return
# No line found to fixup.
existing_lines
.
append
(
self
)
def
get_text
(
self
):
"""
Get the text for the line to save.
"""
line
=
self
.
_line
if
self
.
_make_fixup
:
line
=
line
.
replace
(
"
pick
"
,
"
fixup
"
,
1
)
return
line
todo_lines
=
[]
with
open
(
filename
,
"
r
"
,
encoding
=
"
utf8
"
)
as
todo_file
:
for
line
in
todo_file
:
TodoLine
(
line
).
add_to_list_try_fixup
(
todo_lines
)
with
open
(
filename
,
"
w
"
,
encoding
=
"
utf8
"
)
as
todo_file
:
for
line
in
todo_lines
:
todo_file
.
write
(
line
.
get_text
())
exit
(
subprocess
.
run
([
editor
,
*
sys
.
argv
[
1
:]],
check
=
False
).
returncode
)
This diff is collapsed.
Click to expand it.
tools/torbrowser/tb-dev
0 → 100755
+
715
−
0
View file @
108bab6e
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
sign in
to comment