AgentSkillsCN

get-file-content

从 Azure DevOps Git 仓库中,按指定版本(分支、提交或标签)获取文件内容。可用于检索拉取请求中已更改文件的前后状态。

SKILL.md
--- frontmatter
name: get-file-content
description: >
  Fetch the content of a file from an Azure DevOps Git repository at a given
  version (branch, commit, or tag). Use to retrieve the before/after state of
  files changed in a pull request.

Get File Content

Platform Note

  • macOS/Linux: run .sh scripts
  • Windows: run .ps1 scripts with the same argument order

Run the get-file-content.sh script on macOS/Linux or get-file-content.ps1 on Windows to retrieve file content.

Arguments

#NameRequiredDescription
1organizationNoAzure DevOps organization (default: default_organization)
2projectYesProject name or ID
3repositoryIdYesRepository name or ID
4pathYesFile path in the repo (e.g. /src/app.js)
5versionNoVersion string – commit SHA, branch name, or tag
6versionTypeNoVersion type: branch, commit, or tag (default: branch)

Example

bash
# Get file from a specific branch
bash .github/skills/get-file-content/get-file-content.sh default_organization MyProject MyRepo /src/app.js main branch

# Get file from a specific commit
bash .github/skills/get-file-content/get-file-content.sh default_organization MyProject MyRepo /src/app.js abc123 commit
powershell
# Get file from a specific branch (Windows)
.\github\skills\get-file-content\get-file-content.ps1 default_organization MyProject MyRepo /src/app.js main branch

# Get file from a specific commit (Windows)
.\github\skills\get-file-content\get-file-content.ps1 default_organization MyProject MyRepo /src/app.js abc123 commit

Output

Returns JSON with content containing the file's text content, plus metadata like path, commitId, and objectId.