Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
36e60c5
0.1 版本
piratf Feb 25, 2016
82b67da
chore(exe): 将更新后的 python 脚本打包为 exe 文件
piratf May 3, 2022
be78c3e
fix: 使用 os.path.join() 替代字符串拼接路径
piratf Jan 11, 2026
a75f978
fix: 明确指定文件写入编码
piratf Jan 11, 2026
50b97af
fix: 添加编码转换异常处理
piratf Jan 11, 2026
b9d7f89
fix: 使用 subprocess 替代 os.system 防止命令注入
piratf Jan 11, 2026
999fcdd
feat: 添加完整的异常处理机制
piratf Jan 11, 2026
3075a97
feat: 添加备注长度验证
piratf Jan 11, 2026
fa40c82
feat: 添加 Windows 平台检查
piratf Jan 11, 2026
f03cbcd
feat: 改进帮助信息和使用提示
piratf Jan 11, 2026
4350f58
feat: 添加删除备注功能和帮助系统
piratf Jan 11, 2026
d184502
refactor: 使用 argparse 重构命令行参数解析
piratf Jan 11, 2026
67aedb9
refactor: 重构项目架构,支持文件和文件夹备注
piratf Jan 11, 2026
bbf6111
fix: 修复 desktop.ini 编码问题,提取独立的 storage 层
piratf Jan 11, 2026
e094e9f
refactor: 移除文件备注功能,专注于文件夹备注
piratf Jan 11, 2026
622a0c2
feat: 改进 desktop.ini 编码处理和删除逻辑
piratf Jan 11, 2026
4e67e09
feat: 添加 GitHub Actions CI/CD 配置
piratf Jan 11, 2026
13159b0
refactor: 迁移到 pyproject.toml,改进版本管理
piratf Jan 11, 2026
958417c
style: 运行 ruff 自动格式化代码
piratf Jan 11, 2026
6b75b78
refactor: 删除 sys_encode,使用现代 Python print
piratf Jan 11, 2026
2efe833
chore: 配置统一使用 LF 换行符
piratf Jan 11, 2026
58227ca
refactor: 优化 read_info_tip 编码读取逻辑
piratf Jan 11, 2026
a522c3e
test: 覆盖单元测试和集成测试
piratf Jan 15, 2026
d0dd41b
ci: 优化 GitHub Actions 工作流并配置 pre-push hooks
piratf Jan 24, 2026
783e203
chore: 添加项目构建配置和版本管理
piratf Jan 24, 2026
57376ce
style: 格式化代码文件为 LF 换行符
piratf Jan 24, 2026
4690224
test: 修复测试代码问题并统一换行符
piratf Jan 24, 2026
3065689
refactor: 改进用户提示信息
piratf Jan 24, 2026
3d1fa0a
feat: 增强 release 脚本的安全性和可靠性
piratf Jan 24, 2026
c5a8a7d
feat: 添加编码检测修复和本地打包功能
piratf Jan 24, 2026
6a2a288
ci: 添加 PR 验证工作流并修复主分支名称
piratf Jan 24, 2026
17bac3e
ci: 移除 test.yml 的 pull_request 触发条件
piratf Jan 24, 2026
e98f67b
ci: 简化 test.yml 工作流,移除 artifact 上传
piratf Jan 24, 2026
7ac0f68
chore: 将项目最低 Python 版本从 3.9 提升至 3.11
piratf Jan 25, 2026
06bb844
feat: 添加模糊路径解析功能,支持未加引号的含空格路径
piratf Jan 25, 2026
005ed40
chore: 更新 .python-version 为 3.11.7
piratf Jan 25, 2026
743f387
refactor: path_resolver 使用 Path 对象替代字符串路径
piratf Jan 25, 2026
44fc0ff
refactor: fix path resolver empty directory handling
piratf Jan 25, 2026
de82715
test: migrate CLI tests from unittest.mock to pyfakefs
piratf Jan 25, 2026
4069740
test: force UTF-8 encoding in pytest for emoji support
piratf Jan 25, 2026
68f642e
ci: remove duplicate pull_request workflow, add PR trigger to test.yml
piratf Jan 25, 2026
8e41476
fix: enable UTF-8 mode in PyInstaller spec for Chinese character support
piratf Jan 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
# 统一使用 LF 换行符
* text=auto eol=lf

# Windows 特定文件保持 CRLF
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf

# LFS for large files
dist/* filter=lfs diff=lfs merge=lfs -text
142 changes: 142 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# -*- coding: utf-8 -*-
name: Build and Release

on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:

jobs:
build:
runs-on: windows-latest
strategy:
matrix:
architecture: [x64]
python-version: ['3.11']

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Run tests
run: |
pytest -v --cov=remark --cov-report=term-missing

- name: Install PyInstaller
run: |
pip install pyinstaller

- name: Build executable
run: |
pyinstaller remark.spec --clean

- name: Rename executable with version
run: |
if ($env:GITHUB_REF -match "refs/tags/v(.*)") {
$version = $matches[1]
} else {
$version = "dev"
}
Copy-Item "dist\windows-folder-remark.exe" "dist\windows-folder-remark-$version.exe"

- name: Generate checksum
run: |
if ($env:GITHUB_REF -match "refs/tags/v(.*)") {
$version = $matches[1]
} else {
$version = "dev"
}
$file = "dist\windows-folder-remark-$version.exe"
certutil -hashfile $file SHA256 > "$file.sha256"

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: windows-folder-remark-${{ matrix.architecture }}
path: |
dist/*.exe
dist/*.sha256

release:
needs: build
runs-on: windows-latest
permissions:
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Extract version from tag
id: version
run: |
if ($env:GITHUB_REF -match "refs/tags/v(.*)") {
$version = $matches[1]
echo "version=$version" >> $env:GITHUB_OUTPUT
echo "version=$version"
}

- name: Generate Release Notes
id: release_notes
run: |
$notes = @"
## windows-folder-remark v${{ steps.version.outputs.version }}

### 下载
- `windows-folder-remark-${{ steps.version.outputs.version }}.exe`: 单文件可执行程序,无需安装 Python
- `.sha256` 文件用于验证下载文件的完整性

### 使用方法
```powershell
# 添加备注
.\windows-folder-remark-${{ steps.version.outputs.version }}.exe "C:\MyFolder" "我的备注"

# 查看备注
.\windows-folder-remark-${{ steps.version.outputs.version }}.exe --view "C:\MyFolder"

# 删除备注
.\windows-folder-remark-${{ steps.version.outputs.version }}.exe --delete "C:\MyFolder"

# 交互模式
.\windows-folder-remark-${{ steps.version.outputs.version }}.exe
```

### 验证下载
```powershell
certutil -hashfile windows-folder-remark-${{ steps.version.outputs.version }}.exe SHA256
```
然后对比生成的哈希值与 .sha256 文件中的值是否一致。

### 系统要求
- Windows 7 或更高版本
"@
$notes | Out-File -Encoding UTF8 -FilePath release_notes.txt

- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: windows-folder-remark v${{ steps.version.outputs.version }}
body_path: release_notes.txt
draft: false
prerelease: false
files: |
artifacts/**/*.exe
artifacts/**/*.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69 changes: 69 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Test and Build

on:
pull_request:
branches: [main]
workflow_dispatch:

jobs:
test:
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.11", "3.12", "3.13"]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Run tests
run: pytest -v --cov=remark --cov-report=term-missing

build-verify:
runs-on: windows-latest
needs: test

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Install PyInstaller
run: pip install pyinstaller

- name: Build executable
run: pyinstaller remark.spec --clean

- name: Verify executable
run: |
$exePath = "dist\windows-folder-remark.exe"
if (-not (Test-Path $exePath)) {
Write-Error "Executable not found!"
exit 1
}
& $exePath --help
if ($LASTEXITCODE -ne 0) {
Write-Error "Executable failed to run!"
exit 1
}
Write-Output "Build successful!"
shell: pwsh
35 changes: 33 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
# IDE
.idea
*.spec
build

# Build
build/
dist/
# PyInstaller spec files (keep remark.spec)
# *.spec

# Python
__pycache__/
*.py[cod]
*$py.class
*.egg-info/
.eggs/
.venv/
venv/
*.egg

# Testing
.pytest_cache/
.coverage
htmlcov/
*.cover

# Type checking
.mypy_cache/
.dmypy.json
dmypy.json
.ruff_cache/

# Distribution
*.whl
*.tar.gz
68 changes: 68 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Pre-commit configuration
# https://pre-commit.com/

default_language_version:
python: python3.9

default_stages: [pre-commit]

repos:
# Ruff - 代码检查和格式化
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.4
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

# Pre-commit hooks for general checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace # 删除行尾空格
- id: end-of-file-fixer # 文件末尾添加换行
- id: check-yaml # 检查 YAML 语法
- id: check-toml # 检查 TOML 语法
- id: check-added-large-files # 防止大文件提交
args: ['--maxkb=1000']
- id: check-merge-conflict # 检查合并冲突标记
- id: check-case-conflict # 检查大小写冲突
- id: check-docstring-first # 检查 docstring 是否在代码前

# Mypy - 静态类型检查
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.14.1
hooks:
- id: mypy
additional_dependencies:
- types-setuptools
exclude: ^remark\.py$

# Local hooks - pre-push 阶段(测试 + 构建)
- repo: local
hooks:
- id: run-tests
name: Run tests
entry: pytest -v -m "not slow" --cov=remark --cov-report=term-missing
language: system
stages: [pre-push]
pass_filenames: false

- id: build-exe
name: Build exe (Windows only)
entry: bash -c 'if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then pyinstaller remark.spec --clean; else echo "Skip build on non-Windows"; fi'
language: system
stages: [pre-push]
pass_filenames: false

# 全局排除
exclude: |
^(?:
\.venv/|
\.git/|
\.mypy_cache/|
__pycache__/|
build/|
dist/|
*.egg-info/
)
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11.7
62 changes: 62 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added
- GitHub Actions CI/CD for automated releases
- PyInstaller configuration for Windows executable builds
- Version management script for release automation
- Support for both 32-bit and 64-bit Windows builds

## [2.0.0] - Unreleased

### Added
- UTF-16 encoding detection and conversion for desktop.ini
- User confirmation prompt before encoding conversion
- EncodingConversionCanceled exception for safer error handling
- Smart delete logic: removes InfoTip while preserving other desktop.ini settings
- Top-level exception handling in CLI main()
- Windows platform check before running

### Changed
- Improved desktop.ini read/write operations with encoding safety
- Better error handling with exception-based flow control
- Enhanced folder comment handling with dedicated storage layer
- Refactored command-line argument parsing with argparse

### Fixed
- Fixed desktop.ini encoding issues
- Path handling with spaces using os.path.join()
- Exception handling for encoding conversion

### Removed
- File comment functionality (COM component and Property Store)
- notify_shell_update function (no longer needed)
- File-related imports and handlers

## [1.0] - 2022-05-03

### Added
- Interactive mode with continuous loop for batch processing
- Help system with usage instructions
- Comment length validation
- Complete exception handling mechanism

### Fixed
- Path with spaces handling issue
- Command injection vulnerability (subprocess replaced os.system)
- Encoding conversion exception handling
- Explicit file write encoding specification

### Changed
- Improved help messages and usage prompts
- Packaged as Windows executable

[Unreleased]: https://github.com/piratf/windows-folder-remark/compare/v2.0.0...HEAD
[2.0.0]: https://github.com/piratf/windows-folder-remark/compare/v1.0...v2.0.0
[1.0]: https://github.com/piratf/windows-folder-remark/releases/tag/v1.0
Binary file added desktop.ini
Binary file not shown.
Binary file removed dist/remark/_internal/VCRUNTIME140.dll
Binary file not shown.
Binary file removed dist/remark/_internal/_bz2.pyd
Binary file not shown.
Binary file removed dist/remark/_internal/_decimal.pyd
Binary file not shown.
Binary file removed dist/remark/_internal/_hashlib.pyd
Binary file not shown.
Binary file removed dist/remark/_internal/_lzma.pyd
Binary file not shown.
Binary file removed dist/remark/_internal/_socket.pyd
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed dist/remark/_internal/api-ms-win-crt-heap-l1-1-0.dll
Binary file not shown.
Binary file not shown.
Binary file removed dist/remark/_internal/api-ms-win-crt-math-l1-1-0.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed dist/remark/_internal/api-ms-win-crt-time-l1-1-0.dll
Binary file not shown.
Binary file not shown.
Binary file removed dist/remark/_internal/base_library.zip
Binary file not shown.
Binary file removed dist/remark/_internal/libcrypto-3.dll
Binary file not shown.
Binary file removed dist/remark/_internal/python312.dll
Binary file not shown.
Binary file removed dist/remark/_internal/select.pyd
Binary file not shown.
Binary file removed dist/remark/_internal/ucrtbase.dll
Binary file not shown.
Binary file removed dist/remark/_internal/unicodedata.pyd
Binary file not shown.
Binary file removed dist/remark/remark.exe
Binary file not shown.
Loading