-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
workbench ------------------- - Add CI workflow - Create private setup file bin ------------------- - Change container-nuke volume prune with --all - Introduce list-duplicated-files zsh ------------------- - Skip installing some default aliases - Remove some plugins (because I don't care about aliases) - Add you-should-use plugin to warn about alias commands system ------------------- - Create requirements.yml for Ansible - Replace Peek with Kooha GIF recorder - Add OBS Studio - Add Leafpad GTK based editor - Add Anki - Add test if desktop window system is Wayland - Add wl-clipboard for Wayland - Add Wacom - Remove Lazydocker - Replace Neofetch with Fastfetch pre-commit ------------------- - Upgrade versions - Exclude some files for all hooks p10k ------------------- - Regenerate config nvim ------------------- - Add multiple search plugin
- Loading branch information
Showing
28 changed files
with
326 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: pre-commit | ||
|
||
on: | ||
push: | ||
|
||
env: | ||
# pre-commit action doesn't get installed otherwise | ||
PIP_REQUIRE_VIRTUALENV: false | ||
|
||
jobs: | ||
pre-commit: | ||
if: false # FIXME: disable it for now. | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 3 | ||
# XXX because of gitea. this is ever resolved, remove the line below. | ||
container: catthehacker/ubuntu:act-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.12.4" | ||
|
||
- name: Run symlinks | ||
run: | | ||
export WORKBENCH_PATH="$(pwd)" | ||
./files/symlink | ||
- name: Install Ansible requirements | ||
run: | | ||
python -m pip install ansible | ||
ansible-galaxy collection install -r system/arch/main/requirements.yml | ||
- name: Run pre-commit | ||
uses: pre-commit/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/usr/bin/env python | ||
|
||
# TODO: make it work. | ||
|
||
import argparse | ||
import hashlib | ||
import pathlib | ||
|
||
# List duplicated files | ||
# | ||
# Usage: | ||
# list-duplicated-files <path> | ||
# | ||
# Example: | ||
# For instance, you have the following files. | ||
# . | ||
# ├── 1 | ||
# ├── 2 | ||
# ├── 3 | ||
# ├── bar | ||
# │ ├── 2 | ||
# │ └── 3 | ||
# └── foo | ||
# ├── 1 | ||
# └── 2 | ||
# | ||
# The sha256sum values of e.g. 1 and foo/1 are the same. | ||
# | ||
|
||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser(allow_abbrev=False) | ||
parser.add_argument("path", type=str, help="Path to folder") | ||
args = parser.parse_args() | ||
return args | ||
|
||
|
||
def get_file_hash(file_path): | ||
sha256_hash = hashlib.sha256() | ||
with open(file_path, "rb") as file: | ||
for byte_block in iter(lambda: file.read(4096), b""): | ||
sha256_hash.update(byte_block) | ||
return sha256_hash.hexdigest() | ||
|
||
|
||
def find_duplicate_files(root_path): | ||
duplicate_files = {} | ||
|
||
for file_path in root_path.rglob("*.*"): | ||
sha256_value = "" | ||
if file_path.is_file(): | ||
sha256_value = get_file_hash(file_path) | ||
if sha256_value: | ||
if not duplicate_files.get(sha256_value): | ||
duplicate_files[sha256_value] = [] | ||
duplicate_files[sha256_value].append(file_path) | ||
|
||
return duplicate_files | ||
|
||
|
||
def main(): | ||
args = parse_args() | ||
path = pathlib.Path(args.path) | ||
duplicate_files = find_duplicate_files(path) | ||
|
||
stats = {"files": 0, "groups": 0} | ||
for files in duplicate_files.values(): | ||
if len(files) > 1: | ||
stats["groups"] += 1 | ||
for file in files: | ||
print(file) | ||
stats["files"] += 1 | ||
print(" ") | ||
print(f"Found {stats['files']} duplicated files in {stats['groups']} groups") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Binary file not shown.
Oops, something went wrong.