Skip to content

Commit

Permalink
v0.6.7
Browse files Browse the repository at this point in the history
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
strboul committed Jul 13, 2024
1 parent 62642e1 commit d53fc97
Show file tree
Hide file tree
Showing 28 changed files with 326 additions and 62 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ files/ssh/** filter=git-crypt diff=git-crypt
files/git/allowed_signers filter=git-crypt diff=git-crypt
bin/my-restic filter=git-crypt diff=git-crypt
files/routemonitor/** filter=git-crypt diff=git-crypt
setup.md filter=git-crypt diff=git-crypt
37 changes: 37 additions & 0 deletions .github/workflows/pre-commit.yml
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]
51 changes: 29 additions & 22 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
# See https://pre-commit.com/hooks.html for more hooks
#
fail_fast: true

# always exclude list (see .gitattributes)
exclude: |
(?x)^(
.git-crypt/.*|
files/ssh/.*|
files/routemonitor/.*|
files/git/allowed_signers|
bin/my-restic|
setup.md
)$
repos:
# base hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -17,8 +29,8 @@ repos:
- id: check-yaml
- id: check-json
exclude: |
(?x)(
^files\/nvim\/coc-settings.json
(?x)^(
files/nvim/coc-settings.json
)$
# nvim: lua
Expand All @@ -31,21 +43,21 @@ repos:

# python: black
- repo: https://github.com/psf/black
rev: 24.1.1
rev: 24.4.2
hooks:
- id: black
name: "[py] black"

# python: flake8
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
rev: 7.1.0
hooks:
- id: flake8
name: "[py] flake8"
args: ["--config=files/python/flake8_global.cfg"]

# python: isort
- repo: https://github.com/pycqa/isort
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
Expand All @@ -54,27 +66,27 @@ repos:

# shell: shellcheck
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.6
rev: v0.10.0.1
hooks:
- id: shellcheck
name: "[sh] shellcheck"
exclude: |
(?x)(
^files\/p10k\/p10k.zsh|
^files\/zsh\/navi_keybindings.zsh|
^files\/zsh\/keybindings.zsh
(?x)^(
files/p10k/p10k.zsh|
files/zsh/navi_keybindings.zsh|
files/zsh/keybindings.zsh
)$
# shell: shfmt - requires golang to build
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.7.0-4
rev: v3.8.0-1
hooks:
- id: shfmt
name: "[sh] shfmt"
exclude: |
(?x)(
^files\/p10k\/p10k.zsh|
^files\/zsh\/navi_keybindings.zsh
(?x)^(
files/p10k/p10k.zsh|
files/zsh/navi_keybindings.zsh
)$
# -w Write result to file instead of stdout.
# -i indent two spaces.
Expand All @@ -85,11 +97,11 @@ repos:

# ansible: ansible-lint
- repo: https://github.com/ansible-community/ansible-lint
rev: v24.2.0
rev: v24.7.0
hooks:
- id: ansible-lint
name: "[ansible] ansible-lint"
# ansible-lint doesn't yet accept files/exclude for pre-commit :(
# ansible-lint doesn't yet accept files/exclude for pre-commit.
# https://github.com/ansible/ansible-lint/issues/611
# when fixed, just run this on the yml files in the system dir.
pass_filenames: false
Expand All @@ -101,11 +113,6 @@ repos:
name: "[custom] check text in content"
description: check certain text not exist in the content
language: system
exclude: |
(?x)(
^.git-crypt\/|
^files\/git\/allowed_signers
)
entry: |
python -c '''
import sys, os, re
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Recommended steps to install the parts in the following order.

## Development

- Copy current git hooks to the cloned repository: `cp -R files/git/git_templates/hooks/* .git/hooks`
<details>

- Run `pre-commit install` that installs the hook scripts at `.git/hooks`
Check `setup.md` for more information.

</details>
2 changes: 1 addition & 1 deletion bin/container-nuke
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ remove_images() {

remove_volumes() {
utils__log__info "force removing volumes"
"$COMMAND" volume prune -f || true
"$COMMAND" volume prune --all -f || true
}

remove_build_cache() {
Expand Down
78 changes: 78 additions & 0 deletions bin/list-duplicated-files
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 modified files/git/allowed_signers
Binary file not shown.
Loading

0 comments on commit d53fc97

Please sign in to comment.