Skip to content

Commit dbe8148

Browse files
committed
update docs
1 parent 6fa42d2 commit dbe8148

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed

docs/guide/best-practices/faq.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,60 @@ And add `-D` to get the verbose backtrace and diagnostic info, then you can subm
5555
$ xmake -v -D
5656
```
5757

58+
## How to use git bisect to quickly locate issues? {#use-git-bisect-to-locate-issues}
59+
60+
When you discover that a feature broke after a certain version but aren't sure which commit introduced the issue, you can use xmake's built-in git bisect feature to quickly locate the problem.
61+
62+
git bisect uses a binary search algorithm to quickly locate the first bad commit that introduced the issue by testing different version commits.
63+
64+
### Basic usage
65+
66+
```sh
67+
$ xmake l cli.bisect -g <good_version> -b <bad_version> --gitdir=<xmake_repo_path> -c "<test_command>"
68+
```
69+
70+
Parameter description:
71+
- `-g, --good`: Specify a known good version (tag or commit)
72+
- `-b, --bad`: Specify a known bad version (tag or commit)
73+
- `--gitdir`: Specify the path to the xmake source repository
74+
- `-c, --command`: Specify the test command to verify if the current version is working correctly
75+
76+
### Example
77+
78+
Suppose you found that version v2.9.1 works fine, but version v2.9.2 has issues, and you want to locate which commit introduced the problem:
79+
80+
```sh
81+
$ xmake l cli.bisect -g v2.9.1 -b v2.9.2 --gitdir=/Users/ruki/projects/personal/xmake -c "xrepo remove --all -y; xmake f -a arm64 -cvD -y"
82+
```
83+
84+
This command will:
85+
1. Perform a binary search between v2.9.1 (good version) and v2.9.2 (bad version)
86+
2. For each tested commit, execute the specified test command
87+
3. Automatically mark as good or bad based on test results
88+
4. Finally locate the first commit that introduced the issue
89+
90+
### Output result
91+
92+
After execution completes, it will display results similar to the following:
93+
94+
```
95+
aa278bc7fc0b723a315120bb95531991b7939229 is the first bad commit
96+
97+
commit aa278bc7fc0b723a315120bb95531991b7939229
98+
99+
Author: ruki <[email protected]>
100+
101+
Date: Fri May 10 00:44:57 2024 +0800
102+
103+
improve to system/find_package
104+
105+
xmake/modules/package/manager/system/find_package.lua | 16 +++++++++++++---
106+
107+
1 file changed, 13 insertions(+), 3 deletions(-)
108+
```
109+
110+
This allows you to quickly locate the specific commit and changes that introduced the issue, making it easier to analyze and fix.
111+
58112
## How to see verbose compiling warnings?
59113

60114
```sh

docs/zh/guide/best-practices/faq.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,60 @@ $ xmake [-v|--verbose]
5555
$ xmake -v -D
5656
```
5757

58+
## 如何使用 git bisect 快速定位问题?{#use-git-bisect-to-locate-issues}
59+
60+
当你发现某个功能在某个版本之后出现了问题,但不确定是哪个提交引入的,可以使用 xmake 内置的 git bisect 功能来快速定位问题。
61+
62+
git bisect 使用二分查找算法,通过测试不同版本的提交,快速定位引入问题的第一个坏提交(first bad commit)。
63+
64+
### 基本用法
65+
66+
```sh
67+
$ xmake l cli.bisect -g <good_version> -b <bad_version> --gitdir=<xmake_repo_path> -c "<test_command>"
68+
```
69+
70+
参数说明:
71+
- `-g, --good`: 指定一个已知正常的版本(tag 或 commit)
72+
- `-b, --bad`: 指定一个已知有问题的版本(tag 或 commit)
73+
- `--gitdir`: 指定 xmake 源码仓库的路径
74+
- `-c, --command`: 指定测试命令,用于验证当前版本是否正常
75+
76+
### 示例
77+
78+
假设你发现在 v2.9.1 版本正常,但在 v2.9.2 版本出现了问题,想要定位是哪个提交引入的:
79+
80+
```sh
81+
$ xmake l cli.bisect -g v2.9.1 -b v2.9.2 --gitdir=/Users/ruki/projects/personal/xmake -c "xrepo remove --all -y; xmake f -a arm64 -cvD -y"
82+
```
83+
84+
这个命令会:
85+
1. 在 v2.9.1(好版本)和 v2.9.2(坏版本)之间进行二分查找
86+
2. 对每个测试的提交,执行指定的测试命令
87+
3. 根据测试结果自动标记为 good 或 bad
88+
4. 最终定位到第一个引入问题的提交
89+
90+
### 输出结果
91+
92+
执行完成后,会显示类似如下的结果:
93+
94+
```
95+
aa278bc7fc0b723a315120bb95531991b7939229 is the first bad commit
96+
97+
commit aa278bc7fc0b723a315120bb95531991b7939229
98+
99+
Author: ruki <[email protected]>
100+
101+
Date: Fri May 10 00:44:57 2024 +0800
102+
103+
improve to system/find_package
104+
105+
xmake/modules/package/manager/system/find_package.lua | 16 +++++++++++++---
106+
107+
1 file changed, 13 insertions(+), 3 deletions(-)
108+
```
109+
110+
这样就能快速定位到引入问题的具体提交和修改内容,便于进一步分析和修复。
111+
58112
## 怎样看实时编译警告信息? {#see-verbose-compiling-warnings}
59113

60114
为了避免刷屏,在构建时默认是不实时输出警告信息的,如果想要查看,可以加上 `-w` 选项启用编译警告输出。

0 commit comments

Comments
 (0)