> For the complete documentation index, see [llms.txt](https://docshome.gitbook.io/nginx-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docshome.gitbook.io/nginx-docs/kai-fa/gong-xian-zhi-nan.md).

# 贡献指南

## 获取源码

[Mercurial](https://www.mercurial-scm.org/) 是一个源码存储工具。可使用以下命令源码[仓库](http://hg.nginx.org/nginx?_ga=2.101961729.1619437240.1505835130-1890203964.1497190280)：

```bash
hg clone http://hg.nginx.org/nginx
```

## 格式化变更

变更应根据 nginx 使用的代码样式进行格式化。代码格式化不应该依赖于诸如语法高亮或自动换行等编辑器功能。以下是一些基本规则：

* 最大文本宽度为 80 个字符
* 缩进为四个空格
* 没有 tab（制表符）
* 文件中的逻辑代码块用两行空行分隔

参照现有 nginx 源码的格式，在您的代码中模仿此样式。如果风格与周围的代码相一致，则更改更容易被接受。

提交更改以创建一个 Mercurial [变更集](https://www.mercurial-scm.org/wiki/ChangeSet)（changeset）。请确保指定的 [电子邮件](https://www.mercurial-scm.org/wiki/QuickStart#Setting_a_username) 和变更作者的真实姓名正确无误。

提交消息应是单行简述，后跟一行空行加描述内容。第一行最好不要超过 67 个符号。可以使用 `hg export` 命令获得一个结果变更集 patch：

```diff
# HG changeset patch
# User Filipe Da Silva <username@example.com>
# Date 1368089668 -7200
#      Thu May 09 10:54:28 2013 +0200
# Node ID 2220de0521ca2c0b664a8ea1e201ce1cb90fd7a2
# Parent  822b82191940ef309cd1e6502f94d50d811252a1
Mail: removed surplus ngx_close_connection() call.

It is already called for a peer connection a few lines above.

diff -r 822b82191940 -r 2220de0521ca src/mail/ngx_mail_auth_http_module.c
--- a/src/mail/ngx_mail_auth_http_module.c      Wed May 15 15:04:49 2013 +0400
+++ b/src/mail/ngx_mail_auth_http_module.c      Thu May 09 10:54:28 2013 +0200
@@ -699,7 +699,6 @@ ngx_mail_auth_http_process_headers(ngx_m

                     p = ngx_pnalloc(s->connection->pool, ctx->err.len);
                     if (p == NULL) {
-                        ngx_close_connection(ctx->peer.connection);
                         ngx_destroy_pool(ctx->pool);
                         ngx_mail_session_internal_server_error(s);
                         return;
```

## 提交前

提交更改前，有几点值得思考：

* 建议的变更应能在大部分的 [支持平台](http://nginx.org/en/index.html#tested_os_and_platforms) 上正常工作。
* 尽量说明清楚为什么需要更改，如果可以的话，请提供一个用例。
* 通过测试套件传递您的更改是确保不会导致回归的好方法。可以使用以下命令克隆测试仓库：

```bash
hg clone http://hg.nginx.org/nginx-tests
```

## 提交变更

提议的更改应发送到 [nginx 开发](http://nginx.org/en/support.html#nginx_devel) 邮件列表。提交更改集的首选便捷方法是使用 [patchbomb](https://www.mercurial-scm.org/wiki/PatchbombExtension) 扩展。

## 许可证

提交变更意味着授予项目一个权限以在一个适当的许可证下使用它。

## 原文档

<http://nginx.org/en/docs/contributing_changes.html>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docshome.gitbook.io/nginx-docs/kai-fa/gong-xian-zhi-nan.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
