summaryrefslogtreecommitdiffstats
path: root/docs/content/doc/usage/agit-support.zh-cn.md
blob: de6eba24b23ef6a601be0a719dc367c720b2b9ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
---
date: "2023-05-23T09:00:00+08:00"
title: "Agit 设置"
slug: "agit-setup"
weight: 12
toc: false
draft: false
aliases:
  - /zh-cn/agit-setup
menu:
  sidebar:
    parent: "usage"
    name: "Agit 设置"
    weight: 12
    identifier: "agit-setup"
---

# Agit 设置

在 Gitea `1.13` 版本中,添加了对 [agit](https://git-repo.info/zh/2020/03/agit-flow-and-git-repo/) 的支持。

## 使用 Agit 创建 PR

Agit 允许在推送代码到远程仓库时创建 PR(合并请求)。
通过在推送时使用特定的 refspec(git 中已知的位置标识符),可以实现这一功能。
下面的示例说明了这一点:

```shell
git push origin HEAD:refs/for/master
```

该命令的结构如下:

- `HEAD`:目标分支
- `refs/<for|draft|for-review>/<branch>`:目标 PR 类型
  - `for`:创建一个以 `<branch>` 为目标分支的普通 PR
  - `draft`/`for-review`:目前被静默忽略
- `<branch>/<session>`:要打开 PR 的目标分支
- `-o <topic|title|description>`:PR 的选项
  - `title`:PR 的标题
  - `topic`:PR 应该打开的分支名称
  - `description`:PR 的描述
  - `force-push`:确认强制更新目标分支

下面是另一个高级示例,用于创建一个以 `topic``title``description` 为参数的新 PR,目标分支是 `master````shell
git push origin HEAD:refs/for/master -o topic="Topic of my PR" -o title="Title of the PR" -o description="# The PR Description\nThis can be **any** markdown content.\n- [x] Ok"
```
bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*
 * Copyright 2006 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* $Id$ */

package org.apache.fop.render.afp.tools;

import java.io.IOException;
import java.io.InputStream;

/**
 * A helper class to read structured fields from a MO:DCA document. Each
 * component of a mixed object document is explicitly defined and delimited
 * in the data. This is accomplished through the use of MO:DCA data structures,
 * called structured fields. Structured fields are used to envelop document
 * components and to provide commands and information to applications using
 * the data. Structured fields may contain one or more parameters. Each
 * parameter provides one value from a set of values defined by the architecture.
 * <p/>
 * MO:DCA structured fields consist of two parts: an introducer that identifies
 * the length and type of the structured field, and data that provides the
 * structured field's effect. The data is contained in a set of parameters,
 * which can consist of other data structures and data elements. The maximum
 * length of a structured field is 32767 bytes.
 * <p/>
 */
public class StructuredFieldReader {

    /**
     * The input stream to read
     */
    private InputStream _inputStream = null;

    /**
     * The constructor for the StructuredFieldReader
     * @param inputStream the input stream to process
     */
    public StructuredFieldReader(InputStream inputStream) {

        _inputStream = inputStream;

    }

    /**
     * Get the next structured field as identified by the identifer
     * parameter (this must be a valid MO:DCA structured field.
     * @param identifier the three byte identifier
     * @throws IOException
     */
    public byte[] getNext(byte[] identifier) throws IOException {

        int bufferPointer = 0;
        byte[] bufferData = new byte[identifier.length + 2];
        for (int x = 0; x < identifier.length; x++) {
            bufferData[x] = (byte) 0;
        }

        int c;
        while ((c = _inputStream.read()) > -1) {

            bufferData[bufferPointer] = (byte) c;

            // Check the last characters in the buffer
            int index = 0;
            boolean found = true;

            for (int i = identifier.length - 1; i > -1; i--) {

                int p = bufferPointer - index;
                if (p < 0) {
                    p = bufferData.length + p;
                }

                index++;

                if (identifier[i] != bufferData[p]) {
                    found = false;
                    break;
                }

            }

            if (found) {

                byte[] length = new byte[2];

                int a = bufferPointer - identifier.length;
                if (a < 0) {
                    a = bufferData.length + a;
                }

                int b = bufferPointer - identifier.length - 1;
                if (b < 0) {
                    b = bufferData.length + b;
                }

                length[0] = bufferData[b];
                length[1] = bufferData[a];

                int reclength = ((length[0] & 0xFF) << 8) 
                                + (length[1] & 0xFF) - identifier.length - 2;

                byte[] retval = new byte[reclength];

                _inputStream.read(retval, 0, reclength);

                return retval;

            }

            bufferPointer++;
            if (bufferPointer >= bufferData.length) {
                bufferPointer = 0;
            }

        }

        return new byte[] {
        };

    }

}