Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
regit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software Systems Engineering
regit
Commits
b725c65f
Commit
b725c65f
authored
Mar 17, 2023
by
chrg
Browse files
Options
Downloads
Patches
Plain Diff
Make executable type better
parent
27e94d43
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
regit/__main__.py
+23
-9
23 additions, 9 deletions
regit/__main__.py
with
23 additions
and
9 deletions
regit/__main__.py
+
23
−
9
View file @
b725c65f
...
@@ -14,6 +14,27 @@ from dataclasses import dataclass, field
...
@@ -14,6 +14,27 @@ from dataclasses import dataclass, field
# Some code borrowed from https://github.com/newren/git-filter-repo/blob/main/contrib/filter-repo-demos/lint-history
# Some code borrowed from https://github.com/newren/git-filter-repo/blob/main/contrib/filter-repo-demos/lint-history
class
Executable
(
click
.
ParamType
):
name
=
"
executable
"
def
convert
(
self
,
value
,
param
,
ctx
):
if
"
/
"
in
value
:
exe
=
Path
(
value
)
exe
=
exe
.
absolute
()
if
not
os
.
access
(
exe
,
os
.
X_OK
):
self
.
fail
(
f
"
{
value
!r}
is not an executable file
"
,
param
,
ctx
)
else
:
pp
=
shutil
.
which
(
value
)
if
pp
is
None
:
self
.
fail
(
f
"
Could not find
{
value
!r}
on path, add
'
./
'
if it is a file.
"
,
param
,
ctx
,
)
exe
=
Path
(
pp
)
return
exe
@contextmanager
@contextmanager
def
blob_reader
():
def
blob_reader
():
process
=
subprocess
.
Popen
(
process
=
subprocess
.
Popen
(
...
@@ -44,7 +65,7 @@ class BlobHandler:
...
@@ -44,7 +65,7 @@ class BlobHandler:
is_relevant
:
Callable
[[
Path
],
bool
]
=
lambda
_
:
True
is_relevant
:
Callable
[[
Path
],
bool
]
=
lambda
_
:
True
transform
:
Callable
[[
Path
,
bytes
],
bytes
]
=
lambda
_
,
b
:
b
transform
:
Callable
[[
Path
,
bytes
],
bytes
]
=
lambda
_
,
b
:
b
def
__call__
(
self
,
commit
,
metadata
):
def
__call__
(
self
,
commit
:
fr
.
Commit
,
metadata
):
assert
self
.
filter
is
not
None
assert
self
.
filter
is
not
None
for
change
in
commit
.
file_changes
:
for
change
in
commit
.
file_changes
:
filename
=
Path
(
change
.
filename
.
decode
(
"
utf-8
"
))
filename
=
Path
(
change
.
filename
.
decode
(
"
utf-8
"
))
...
@@ -111,7 +132,7 @@ def transform_program(program: Path, args: tuple[str], folder: Path):
...
@@ -111,7 +132,7 @@ def transform_program(program: Path, args: tuple[str], folder: Path):
@click.argument
(
@click.argument
(
"
program
"
,
"
program
"
,
# help="The program to execute on each file",
# help="The program to execute on each file",
type
=
click
.
Path
(
executable
=
True
,
path_type
=
Path
),
type
=
Executable
(
),
)
)
@click.argument
(
@click.argument
(
"
args
"
,
"
args
"
,
...
@@ -137,13 +158,6 @@ def regit(
...
@@ -137,13 +158,6 @@ def regit(
else
:
else
:
repo
=
git
.
Repo
.
clone_from
(
url
=
repo
,
to_path
=
output
)
repo
=
git
.
Repo
.
clone_from
(
url
=
repo
,
to_path
=
output
)
if
program
.
exists
():
program
=
program
.
absolute
()
else
:
pp
=
shutil
.
which
(
str
(
program
))
assert
pp
is
not
None
program
=
Path
(
pp
)
os
.
chdir
(
output
)
os
.
chdir
(
output
)
options
=
fr
.
FilteringOptions
.
parse_args
([],
error_on_empty
=
False
)
options
=
fr
.
FilteringOptions
.
parse_args
([],
error_on_empty
=
False
)
...
...
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