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
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
clairehurst
Tor Browser
Commits
ae4c538d
Commit
ae4c538d
authored
1 year ago
by
henry
Committed by
richard
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Bug 41803 - Add some developer tools for working on tor-browser.
parent
e6cc145a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Expand all
Hide 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 @
ae4c538d
#!/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 @
ae4c538d
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