Skip to content

Drootkit/7z-gitignore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

7-Zip 26.00 中文说明

版本信息

  • 版本: 7-Zip 26.00
  • 版权: Copyright (C) 1999-2026 Igor Pavlov
  • 源码: 基于 7-Zip 官方源码修改

新增功能

1. .gitignore 支持

在压缩对话框中新增 "Use .gitignore" 选项(默认关闭)。

当启用此选项时:

  1. 自动查找源目录中的 .gitignore 文件
  2. 如果未找到 .gitignore 文件,弹出错误提示并阻止压缩
  3. 如果找到 .gitignore 文件,解析其中的规则并过滤要压缩的文件

支持的 .gitignore 模式

模式类型 示例 说明
注释 # 这是注释 # 开头的行
空行 (空行) 忽略空行
简单文件名 *.log 匹配任意目录下的同名文件
目录 node_modules/ 匹配目录
双通配符 **/*.pyc 递归匹配任意子目录
否定规则 !readme.txt 排除但仍包含指定文件
字符类 file[1-3].txt 匹配字符范围内的文件
问号 file?.txt 匹配单个字符
根目录限定 /secrets.key 仅匹配根目录

修改的文件

1. GUI 对话框相关

文件路径 修改内容
CPP\7zip\UI\GUI\CompressDialogRes.h 添加资源 ID IDX_COMPRESS_USE_GITIGNORE
CPP\7zip\UI\GUI\CompressDialog.rc 添加复选框控件
CPP\7zip\UI\GUI\CompressDialog.h 添加 UseGitignore 成员变量
CPP\7zip\UI\GUI\CompressDialog.cpp 添加复选框状态读取/保存逻辑

2. 核心压缩逻辑

文件路径 修改内容
CPP\7zip\UI\Common\Update.h CUpdateOptions 结构体中添加 UseGitignore 成员
CPP\7zip\UI\GUI\UpdateGUI.cpp 添加 .gitignore 解析和应用逻辑

3. 编译脚本

文件路径 说明
build_all.bat 一键编译脚本,输出到 release 目录
build_7zz.bat 编译 7zz.exe (控制台版本)
build_7zG.bat 编译 7zG.exe (GUI 版本)
build_7zFM.bat 编译 7zFM.exe (文件管理器)

使用方法

编译

运行 build_all.bat 编译所有版本:

cd 7z2600-src
build_all.bat

编译产物将输出到 release 目录:

release\
├── 7zz.exe   # 控制台版本
├── 7zG.exe    # GUI 版本
└── 7zFM.exe   # 文件管理器

使用 .gitignore 功能

方法一:使用 GUI (7zG.exe 或 7zFM.exe)

  1. 运行 7zG.exe7zFM.exe
  2. 选择要压缩的文件夹
  3. 在压缩对话框中,勾选 "Options" 区域中的 "Use .gitignore" 复选框
  4. 点击确定开始压缩

界面截图位置

image-20260419235251049

行为说明

  • 未找到 .gitignore: 如果启用了 "Use .gitignore" 但在源目录中未找到 .gitignore 文件,会弹出错误提示:

    .gitignore file not found in the selected directory.
    
    The 'Use .gitignore' option requires a .gitignore file to filter files.
    
  • 成功应用: 找到 .gitignore 后,会自动解析规则并过滤文件


测试

测试项目位于 test\Havoc\,包含:

  • 完整的 .gitignore 测试文件(26种模式类型)
  • 各种测试文件用于验证过滤规则

测试步骤:

  1. 运行 release\7zG.exe
  2. 选择 test\Havoc 目录
  3. 勾选 "Use .gitignore"
  4. 执行压缩并验证结果

注意事项

  1. 默认关闭: 此功能默认关闭,不会影响现有用户的使用习惯
  2. 仅支持 ASCII: 当前版本仅支持 ASCII 字符的 .gitignore 模式
  3. 性能: 大型项目的 .gitignore 规则可能会影响压缩初始化的速度

许可证

本程序基于 7-Zip 26.00 官方源码修改,遵循 GNU LGPL 许可证(除 unRAR 部分)。

详细许可证信息请参阅 DOC\License.txtDOC\unRarLicense.txt

About

The 7z compression tool has added filtering functionality based on .gitignore, making it suitable for transferring internal coding projects.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages