代码之家  ›  专栏  ›  技术社区  ›  scopchanov

选择Git时如何有条件地生成文件?

  •  0
  • scopchanov  · 技术社区  · 7 年前

    为了加快Qt Creator的工作流程,我创建了一个JSON格式的自定义项目向导,并在其中添加了一个 Summary page :

    {
        "trDisplayName": "Project Management",
        "trShortTitle": "Summary",
        "typeId": "Summary"
    }
    

    File generator .gitattributes .gitignore

    {
        "source": ".gitattributes",
        "target": "%{TargetPath}/.gitattributes"
    },
    {
        "source": ".gitignore",
        "target": "%{TargetPath}/.gitignore"
    }
    

    文件 摘要页 说:

    它将VersionControl设置为正在使用的版本控制系统的ID

    VersionControl 变量及其值。

    如何达到预期的效果?

    1 回复  |  直到 7 年前
        1
  •  0
  •   scopchanov    7 年前

    我建议您采用以下解决方案:

    1. 将键盘快捷键指定给 Wizard.Inspect

      工具 选项 -&燃气轮机; 环境 键盘 快捷方式

    2. 启动自定义向导并导航到 摘要页

    3. 按所选按钮

      这将打开一个窗口,列出触发操作时向导中所有已定义的字段和变量。您可以在那里找到:

      Key            | Type    | Value | Eval
      VersionControl | QString | G.Git | G.Git
      
    4. 文件生成器

      {
          "source": ".gitattributes",
          "target": "%{TargetPath}/.gitattributes",
          "condition": "%{JS: '%{VersionControl}' === 'G.Git'}"
      },
      {
          "source": ".gitignore",
          "target": "%{TargetPath}/.gitignore",
          "condition": "%{JS: '%{VersionControl}' === 'G.Git'}"
      }
      
    推荐文章