跳转至

Global Branching in VS Code workspaces(VS Code 工作区中的全局分支(Global Branching))

:::callout{theme="neutral"} Global Branching in VS Code workspaces is supported for Python Transforms repositories and TypeScript v1 function repositories. For the full list of resource types that support Global Branching, review the integrations documentation. :::

When working in VS Code, you can create and access global branches and use other supported workflows for Python transforms and TypeScript v1 function repositories. These workflows are available both in VS Code workspaces deployed on Palantir infrastructure and in local VS Code through the Palantir extension for Visual Studio Code.

Global branches and Code Repositories branches

A repository in VS Code has two kinds of branches:

  • A Code Repositories branch is the underlying git branch of your repository.
  • A global branch can contain changes across multiple Palantir applications, allowing you to develop and test an end-to-end workflow on a single branch. Global branches must be based on the main branch of the repository.

In the Palantir extension, the tabbed branch selector lets you create and check out both Code Repositories branches and global branches from one place.

The tabbed branch selector in the Palantir panel of the VS Code sidebar, with the Global branch tab selected.

Learn more about branch options in Code Repositories..

Branch taskbar

When you open a supported repository in a VS Code workspace, the branch taskbar appears as a blue bar at the bottom of the editor on the Code page. The taskbar displays your active branch and keeps it in sync with VS Code. The branch reflected in the terminal, the Command Palette, and the editor always matches the branch shown in the taskbar.

The taskbar is available in VS Code workspaces only. In local VS Code, use the Palantir extension to view and switch your branch.

Create a global branch

You can create a global branch from any of the following entry points:

  • Branch taskbar (VS Code workspaces only): Open the branch selector in the taskbar and create a new branch.
  • Palantir extension (VS Code workspaces and local VS Code): Open the tabbed branch selector in the Palantir panel of the sidebar, select the Global branch tab, and create a new branch.
  • Command Palette (VS Code workspaces and local VS Code): Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux), then run Palantir: Create Global Branch.
  • Branches page in Code Workspace: Create a global branch from the repository's Branches page.

From any of these entry points, the create branch dialog opens.

Check out a global branch

You can check out an existing global branch from any of the following entry points:

  • Branch taskbar (VS Code workspaces only): Open the branch selector in the taskbar and choose a branch.
  • Palantir extension (VS Code workspaces and local VS Code): Open the tabbed branch selector in the Palantir panel of the sidebar and choose a branch from the Global branch tab.
  • Command Palette (VS Code workspaces and local VS Code): Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux), then run Palantir: Checkout Global Branch.

Aside from the branch taskbar, each entry point opens the same branch picker, which groups branches into sections to help you find the relevant branch quickly:

  • main branch
  • Your branches containing this repository
  • Your branches
  • All other branches

The global branch checkout picker in VS Code, showing branches grouped into sections.

The following behaviors apply when checking out a branch:

  • Adding a repository to a branch: If the repository is not yet on the branch you select, you are prompted to add it before the checkout completes.
  • Uncommitted changes: If you have uncommitted changes, a dialog prompts you to resolve them before the checkout or add-to-branch operation proceeds. This prevents your editor from getting out of sync with your active branch.

Develop transforms on a branch

You can develop Python transforms on a global branch. The preview and build panels run against the branch you currently have checked out.

Learn more about developing Python transforms.

Develop functions on a branch

For TypeScript v1 function repositories, these panels also operate in the context of your active global branch:

  • Live preview: Preview your functions against the resources on the branch.
  • Published preview: Preview the function versions you have published on the branch.
  • Resource imports: Import and modify the Ontology resources available to your functions.

You can publish function versions on a global branch by tagging them. Tag a version from the Tags page in your VS Code workspace or with the Tag Version action in the Palantir extension. While you are on a global branch, the tag is created against that branch.

Learn more about developing, publishing, consuming, rebasing, and merging functions on a branch..


中文翻译


VS Code 工作区中的全局分支(Global Branching)

:::callout{theme="neutral"} VS Code 工作区中的全局分支功能支持 Python Transforms 仓库和 TypeScript v1 函数仓库。有关支持全局分支的完整资源类型列表,请参阅集成文档。 :::

在 VS Code 中工作时,您可以创建和访问全局分支(global branches),并对 Python transforms 和 TypeScript v1 函数仓库使用其他受支持的工作流程。 这些工作流程既适用于部署在 Palantir 基础设施上的 VS Code 工作区,也适用于通过 Palantir extension for Visual Studio Code 在本地 VS Code 中使用。

全局分支与代码仓库分支(Code Repositories branches)

VS Code 中的仓库包含两种分支:

  • 代码仓库分支是仓库底层的 git 分支。
  • 全局分支可以包含跨多个 Palantir 应用程序的变更,让您能够在单个分支上开发和测试端到端工作流程。全局分支必须基于仓库的 main 分支。

在 Palantir 扩展中,选项卡式分支选择器让您可以在一个位置创建和签出代码仓库分支与全局分支。

VS Code 侧边栏 Palantir 面板中的选项卡式分支选择器,已选中全局分支选项卡。

了解更多关于代码仓库中的分支选项

分支任务栏(Branch taskbar)

当您在 VS Code 工作区中打开受支持的仓库时,分支任务栏会以蓝色条形式显示在编辑器底部的代码页面上。任务栏会显示您的活动分支,并使其与 VS Code 保持同步。终端、命令面板和编辑器中反映的分支始终与任务栏中显示的分支一致。

任务栏仅在 VS Code 工作区中可用。在本地 VS Code 中,请使用 Palantir 扩展来查看和切换分支。

创建全局分支

您可以通过以下任一入口点创建全局分支:

  • 分支任务栏(仅限 VS Code 工作区):打开任务栏中的分支选择器并创建新分支。
  • Palantir 扩展(VS Code 工作区和本地 VS Code):打开侧边栏 Palantir 面板中的选项卡式分支选择器,选择全局分支选项卡,然后创建新分支。
  • 命令面板(VS Code 工作区和本地 VS Code):按下 Cmd+Shift+P(macOS)或 Ctrl+Shift+P(Windows/Linux),然后运行 Palantir: Create Global Branch
  • 代码工作区中的分支页面:从仓库的分支页面创建全局分支。

从以上任一入口点操作,都会打开创建分支对话框。

签出全局分支

您可以通过以下任一入口点签出现有的全局分支:

  • 分支任务栏(仅限 VS Code 工作区):打开任务栏中的分支选择器并选择一个分支。
  • Palantir 扩展(VS Code 工作区和本地 VS Code):打开侧边栏 Palantir 面板中的选项卡式分支选择器,然后从全局分支选项卡中选择一个分支。
  • 命令面板(VS Code 工作区和本地 VS Code):按下 Cmd+Shift+P(macOS)或 Ctrl+Shift+P(Windows/Linux),然后运行 Palantir: Checkout Global Branch

除分支任务栏外,每个入口点都会打开相同的分支选择器,该选择器将分支分组,帮助您快速找到相关分支:

  • main 分支
  • 您包含此仓库的分支
  • 您的分支
  • 所有其他分支

VS Code 中的全局分支签出选择器,显示按部分分组的分支。

签出分支时适用以下行为:

  • 将仓库添加到分支: 如果仓库尚未位于您选择的分支上,系统会提示您在签出完成前添加该仓库。
  • 未提交的更改: 如果您有未提交的更改,对话框会提示您在签出或添加到分支操作继续之前解决这些更改。这可以防止您的编辑器与活动分支不同步。

在分支上开发转换(Transforms)

您可以在全局分支上开发 Python transforms。预览构建面板会针对您当前签出的分支运行。

了解更多关于开发 Python transforms 的信息。

在分支上开发函数(Functions)

对于 TypeScript v1 函数仓库,以下面板也会在您的活动全局分支上下文中运行:

您可以通过标记(tagging)在全局分支上发布函数版本。在 VS Code 工作区的标签页面或使用 Palantir 扩展中的 Tag Version 操作来标记版本。当您在全局分支上时,标签将针对该分支创建。

了解更多关于在分支上开发、发布、重定基(rebasing)和合并函数的信息。