Skip to content

Commit

Permalink
Test revert to 65c5863 (Merge branch vp/support-git-2.43, 2024-06-15)
Browse files Browse the repository at this point in the history
  • Loading branch information
newren committed Jul 7, 2024
1 parent 571f1c1 commit d7ca2de
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 296 deletions.
7 changes: 0 additions & 7 deletions .github/dependabot.yml

This file was deleted.

8 changes: 5 additions & 3 deletions Documentation/git-filter-repo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -572,9 +572,11 @@ history rewrite are roughly as follows:
hosting provider about how to remove any server-side references
to the old commits (example:
https://docs.gitlab.com/ee/user/project/repository/reducing_the_repo_size_using_git.html[GitLab's
excellent docs on reducing repository size], or
https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository#fully-removing-the-data-from-github[the
first and second steps under "Fully removing the data from GitHub"]).
excellent docs on reducing repository size], or just the warning
box that references "GitHub support" from
https://docs.github.com/en/github/authenticating-to-github/removing-sensitive-data-from-a-repository[GitHub's
otherwise dangerously out-of-date docs on removing sensitive
data]).

6. (Optional) Some additional considerations

Expand Down
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,15 @@ github_release: update_docs

pypi_release: # Has an implicit dependency on github_release because...
# Upload to PyPI, automatically picking tag created by github_release
python3 -m venv venv
venv/bin/pip install --upgrade pip
venv/bin/pip install build twine
venv/bin/pyproject-build
cd release && python3 -m venv venv
cd release && venv/bin/pip3 install --upgrade setuptools pip
cd release && venv/bin/pip3 install twine wheel
cd release && venv/bin/python3 setup.py sdist bdist_wheel
# Note: hope you remember password for pypi, but username is 'newren'
venv/bin/twine upload dist/*
cd release && venv/bin/twine upload dist/*
# Remove temporary file(s)
rm -rf dist/ venv/ git_filter_repo.egg-info/
cd release && rm -f README.md git-filter-repo git_filter_repo.py
cd release && rm -rf .eggs/ build/ venv/ git_filter_repo.egg-info/

# NOTE TO FUTURE SELF: If you accidentally push a bad release, you can remove
# all but the git-filter-repo-$VERSION.tar.xz asset with
Expand Down
19 changes: 8 additions & 11 deletions contrib/filter-repo-demos/clean-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CheckIgnores:
self.ignored = set()
self.okay = set()

cmd = 'git check-ignore --stdin --verbose --non-matching --no-index -z'
cmd = 'git check-ignore --stdin --verbose --non-matching --no-index'
self.check_ignore_process = subprocess.Popen(cmd.split(),
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
Expand All @@ -46,20 +46,17 @@ class CheckIgnores:
elif name in self.okay:
continue
else:
self.check_ignore_process.stdin.write(name+b'\0')
self.check_ignore_process.stdin.write(name+b'\n')
self.check_ignore_process.stdin.flush()
result = os.read(self.check_ignore_process.stdout.fileno(), 65535).rstrip(b'\0')
(source, linenum, pattern, pathname) = result.split(b"\0")
result = self.check_ignore_process.stdout.readline().rstrip(b'\n')
(rest, pathname) = result.split(b"\t")
if name != pathname:
raise SystemExit("Error: Passed {} but got {}".format(name, pathname))
if not source and not linenum and not pattern:
if rest == b'::':
self.okay.add(name)
else:
if pattern[0:1] == b"!":
self.okay.add(name)
else:
self.ignored.add(name)
ignored.add(name)
self.ignored.add(name)
ignored.add(name)

return ignored

Expand All @@ -72,7 +69,7 @@ class CheckIgnores:

def main():
checker = CheckIgnores()
args = fr.FilteringOptions.parse_args(sys.argv[1:], error_on_empty = False)
args = fr.FilteringOptions.parse_args(sys.argv[1:])
filter = fr.RepoFilter(args, commit_callback=checker.skip_ignores)
filter.run()

Expand Down
8 changes: 2 additions & 6 deletions contrib/filter-repo-demos/lint-history
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ near the top of git-filter-repo.
# about filenames, then this program could be replaced by a "one-liner"; e.g.
# git filter-repo --force --blob-callback '
# if not b"\0" in blob.data[0:8192]:
# filename = ".git/info/tmpfile"
# filename = '.git/info/tmpfile'
# with open(filename, "wb") as f:
# f.write(blob.data)
# subprocess.check_call(["lint_program", "--some", "arg", filename])
Expand Down Expand Up @@ -104,8 +104,6 @@ parser.add_argument('command', nargs=argparse.REMAINDER,
lint_args = parser.parse_args()
if not lint_args.command:
raise SystemExit("Error: Need to specify a lint command")
if len(lint_args.command) > 1 and lint_args.command[0] == '--':
lint_args.command.pop(0)

tmpdir = None
blobs_handled = {}
Expand Down Expand Up @@ -164,7 +162,7 @@ if lint_args.relevant:
lint_args.filenames_important = True
input_args = []
if lint_args.refs:
input_args = ["--refs",] + lint_args.refs
input_args = ["--args",] + lint_args.refs
args = fr.FilteringOptions.parse_args(input_args, error_on_empty = False)
args.force = True
if lint_args.filenames_important:
Expand All @@ -177,7 +175,5 @@ if lint_args.filenames_important:
cat_file_process.stdin.close()
cat_file_process.wait()
else:
if not os.path.exists('.git/info'):
os.makedirs('.git/info')
filter = fr.RepoFilter(args, blob_callback=lint_non_binary_blobs)
filter.run()
31 changes: 6 additions & 25 deletions git-filter-repo
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@ __all__ = ["Blob", "Reset", "FileChange", "Commit", "Tag", "Progress",
"string_to_date", "date_to_string",
"record_id_rename", "GitUtils", "FilteringOptions", "RepoFilter"]

# The globals to make visible to callbacks. They will see all our imports for
# free, as well as our public API.
public_globals = ["__builtins__", "argparse", "collections", "fnmatch",
"gettext", "io", "os", "platform", "re", "shutil",
"subprocess", "sys", "time", "textwrap", "tzinfo",
"timedelta", "datetime"] + __all__

deleted_hash = b'0'*40
write_marks = True
date_format_permissive = True
Expand Down Expand Up @@ -1818,7 +1811,6 @@ EXAMPLES
"paths; you also need a filter to select them."))

helpers = parser.add_argument_group(title=_("Path shortcuts"))
helpers.add_argument('--paths', help=argparse.SUPPRESS, metavar='IGNORE')
helpers.add_argument('--paths-from-file', metavar='FILENAME',
type=os.fsencode,
action=FilteringOptions.FileWithPathsFilter, dest='path_changes',
Expand Down Expand Up @@ -1972,10 +1964,6 @@ EXAMPLES
location.add_argument('--target', type=os.fsencode,
help=_("Git repository to overwrite with filtered history"))

order = parser.add_argument_group(title=_("Ordering of commits"))
order.add_argument('--date-order', action='store_true',
help=_("Processes commits in commit timestamp order."))

misc = parser.add_argument_group(title=_("Miscellaneous options"))
misc.add_argument('--help', '-h', action='store_true',
help=_("Show this help message and exit."))
Expand Down Expand Up @@ -2209,8 +2197,6 @@ EXAMPLES
if args.help:
parser.print_help()
raise SystemExit()
if args.paths:
raise SystemExit("Error: Option `--paths` unrecognized; did you mean --path or --paths-from-file?")
if args.version:
GitUtils.print_my_version()
raise SystemExit()
Expand Down Expand Up @@ -2851,11 +2837,9 @@ class RepoFilter(object):

def _handle_arg_callbacks(self):
def make_callback(argname, str):
callback_globals = {g: globals()[g] for g in public_globals}
callback_locals = {}
exec('def callback({}, _do_not_use_this_var = None):\n'.format(argname)+
' '+'\n '.join(str.splitlines()), callback_globals, callback_locals)
return callback_locals['callback']
' '+'\n '.join(str.splitlines()), globals())
return callback #namespace['callback']
def handle(type):
callback_field = '_{}_callback'.format(type)
code_string = getattr(self._args, type+'_callback')
Expand Down Expand Up @@ -3416,6 +3400,10 @@ class RepoFilter(object):
commit.file_changes = [v for k,v in sorted(new_file_changes.items())]

def _tweak_commit(self, commit, aux_info):
# Change the commit message according to callback
if not self._args.preserve_commit_hashes:
commit.message = self._hash_re.sub(self._translate_commit_hash,
commit.message)
if self._args.replace_message:
for literal, replacement in self._args.replace_message['literals']:
commit.message = commit.message.replace(literal, replacement)
Expand All @@ -3424,11 +3412,6 @@ class RepoFilter(object):
if self._message_callback:
commit.message = self._message_callback(commit.message)

# Change the commit message according to callback
if not self._args.preserve_commit_hashes:
commit.message = self._hash_re.sub(self._translate_commit_hash,
commit.message)

# Change the author & committer according to mailmap rules
args = self._args
if args.mailmap:
Expand Down Expand Up @@ -3678,8 +3661,6 @@ class RepoFilter(object):
if self._args.preserve_commit_encoding is not None: # pragma: no cover
reencode = 'no' if self._args.preserve_commit_encoding else 'yes'
extra_flags.append('--reencode='+reencode)
if self._args.date_order:
extra_flags.append('--date-order')
location = ['-C', self._args.source] if self._args.source else []
fep_cmd = ['git'] + location + ['fast-export', '--show-original-ids',
'--signed-tags=strip', '--tag-of-filtered-object=rewrite',
Expand Down
45 changes: 0 additions & 45 deletions pyproject.toml

This file was deleted.

32 changes: 32 additions & 0 deletions release/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[metadata]
name = git-filter-repo
url = https://github.com/newren/git-filter-repo
project_urls =
Source = https://github.com/newren/git-filter-repo
Issues = https://github.com/newren/git-filter-repo/issues/
description = Quickly rewrite git repository history
long_description = file: README.md
long_description_content_type = text/markdown
classifiers =
Development Status :: 4 - Beta
Operating System :: OS Independent
Programming Language :: Python
License :: OSI Approved :: MIT License
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
platforms = any
license = MIT

[options]
scripts = git-filter-repo
py_modules = git_filter_repo
python_requires = >= 3.5
setup_requires = setuptools_scm

[bdist_wheel]
universal = 1
21 changes: 21 additions & 0 deletions release/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from setuptools import setup
import os


def link_parent(src, target=None):
if target is None:
target = src
try:
os.symlink(os.path.join("..", src), target)
except FileExistsError:
pass


for f in ['git-filter-repo', 'README.md']:
link_parent(f)

link_parent('git-filter-repo', 'git_filter_repo.py')


setup(use_scm_version=dict(root="..", relative_to=__file__),
entry_points={'console_scripts': ['git-filter-repo = git_filter_repo:main']})
2 changes: 1 addition & 1 deletion t/run_coverage
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ exitcode=$?
set -e

cd $tmpdir
coverage3 combine -q
coverage3 combine
coverage3 html -d $orig_dir/report
coverage3 report -m
cd $orig_dir
Expand Down
53 changes: 0 additions & 53 deletions t/t9390-filter-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,6 @@ test_expect_success '--paths-from-file' '
)
'

test_expect_success '--paths does not mean --paths-from-file' '
setup_path_rename &&
(
git clone file://"$(pwd)"/path_rename paths_misuse &&
cd paths_misuse &&
test_must_fail git filter-repo --paths values/large 2>../err &&
grep "Error: Option.*--paths.*unrecognized; did you" ../err &&
rm ../err
)
'

create_path_filtering_and_renaming() {
test -d path_filtering_and_renaming && return

Expand Down Expand Up @@ -1474,46 +1461,6 @@ test_expect_success '--target' '
test_cmp target/expect target/actual
'

test_expect_success '--date-order' '
test_create_repo date_order &&
(
cd date_order &&
git fast-import --quiet <$DATA/date-order &&
# First, verify that without date-order, C is before B
cat <<-EOF >expect-normal &&
Initial
A
C
B
D
merge
EOF
git filter-repo --force --message-callback "
with open(\"messages.txt\", \"ab\") as f:
f.write(message)
return message
" &&
test_cmp expect-normal messages.txt &&
# Next, verify that with date-order, C and B are reversed
rm messages.txt &&
cat <<-EOF >expect &&
Initial
A
B
C
D
merge
EOF
git filter-repo --date-order --force --message-callback "
with open(\"messages.txt\", \"ab\") as f:
f.write(message)
return message
" &&
test_cmp expect messages.txt
)
'

test_expect_success '--refs' '
setup_analyze_me &&
git init refs &&
Expand Down
Loading

0 comments on commit d7ca2de

Please sign in to comment.