diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 57995a43..00000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -version: 2 -updates: - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "monthly" \ No newline at end of file diff --git a/Documentation/git-filter-repo.txt b/Documentation/git-filter-repo.txt index bb00203f..576489b6 100644 --- a/Documentation/git-filter-repo.txt +++ b/Documentation/git-filter-repo.txt @@ -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 diff --git a/Makefile b/Makefile index d50f3bbc..470bfde1 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/contrib/filter-repo-demos/clean-ignore b/contrib/filter-repo-demos/clean-ignore index a8427e8c..23287e13 100755 --- a/contrib/filter-repo-demos/clean-ignore +++ b/contrib/filter-repo-demos/clean-ignore @@ -55,11 +55,8 @@ class CheckIgnores: if not source and not linenum and not pattern: 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 diff --git a/contrib/filter-repo-demos/lint-history b/contrib/filter-repo-demos/lint-history index 22061962..61967b73 100755 --- a/contrib/filter-repo-demos/lint-history +++ b/contrib/filter-repo-demos/lint-history @@ -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]) @@ -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 = {} @@ -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: @@ -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() diff --git a/git-filter-repo b/git-filter-repo index 3dfe5569..e438c38c 100755 --- a/git-filter-repo +++ b/git-filter-repo @@ -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 @@ -2851,11 +2844,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') diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index e6cee7a5..00000000 --- a/pyproject.toml +++ /dev/null @@ -1,45 +0,0 @@ -[project] -name = "git-filter-repo" -description = "Quickly rewrite git repository history" -authors = [ - {name = "Elijah Newren", email = "newren@gmail.com"} -] -readme = "README.md" -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.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", -] -license.text = "MIT" -requires-python = ">= 3.5" -dynamic = ["version"] - -[project.urls] -Homepage = "https://github.com/newren/git-filter-repo" -Issues = "https://github.com/newren/git-filter-repo/issues/" -Source = "https://github.com/newren/git-filter-repo" - -[project.scripts] -git-filter-repo = "git_filter_repo:main" - -[build-system] -requires = ["setuptools>=61", "setuptools_scm>=8.0", "wheel"] -build-backend = "setuptools.build_meta" - -[tool.setuptools] -py-modules = ["git_filter_repo"] - -[tool.setuptools_scm] -# This section intentionally left blank diff --git a/release/setup.cfg b/release/setup.cfg new file mode 100644 index 00000000..078f3ff5 --- /dev/null +++ b/release/setup.cfg @@ -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 diff --git a/release/setup.py b/release/setup.py new file mode 100644 index 00000000..0e36611a --- /dev/null +++ b/release/setup.py @@ -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']}) diff --git a/t/run_coverage b/t/run_coverage index be5e8a89..5517459b 100755 --- a/t/run_coverage +++ b/t/run_coverage @@ -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 diff --git a/t/t9391-filter-repo-lib-usage.sh b/t/t9391-filter-repo-lib-usage.sh index 192eacff..6e62a70e 100755 --- a/t/t9391-filter-repo-lib-usage.sh +++ b/t/t9391-filter-repo-lib-usage.sh @@ -205,44 +205,6 @@ test_expect_success 'lint-history' ' ) ' -test_expect_success 'lint-history --refs' ' - test_create_repo lint-history-only-some-refs && - ( - cd lint-history-only-some-refs && - test_commit a somefile bad && - test_commit b notherfile baaad && - test_commit c whatever baaaaaad && - git checkout -b mybranch HEAD~1 && - test_commit d somefile baaaaaaaad && - test_commit e whatever "baaaaaaaaaad to the bone" && - - cat <<-EOF >linter.sh && - #!/bin/bash - cat \$1 | tr -d a >tmp - mv tmp \$1 - EOF - chmod u+x linter.sh && - - PATH=$PATH:. $CONTRIB_DIR/lint-history --refs master..mybranch -- linter.sh && - - echo bd >expect && - echo bd to the bone >long-expect && - - # Verify master is untouched - git checkout master && - ! test_cmp somefile expect && - ! test_cmp notherfile expect && - ! test_cmp whatever expect && - - # Verify that files touched on the branch are tweaked - git checkout mybranch && - test_cmp somefile expect && - ! test_cmp notherfile expect && - test_cmp whatever long-expect - - ) -' - test_expect_success 'clean-ignore with emoji in filenames' ' test_create_repo clean-ignore && (