mirror of
https://github.com/cmderdev/cmder.git
synced 2026-02-24 22:16:08 +08:00
Merge branch 'master' into upstream-development
* master: Bump peter-evans/create-pull-request from 7 to 8 Bump actions/upload-artifact from 5 to 6 Update Dependabot configuration for GitHub Actions Add success conditionals to build and package summary steps Add missing success conditionals to CodeQL and branches workflows Add success conditionals to upload summary and separate test completion step Improve pluralization clarity, fix test table headers, and add hash comment Refactor artifact summary to use loop and improve pluralization Add success conditionals to test summary steps Add GITHUB_STEP_SUMMARY to all CI/CD workflows Initial plan ⬆️ Update dependencies (clink v1.9.5) Clean luacheck warning. Fix branch name in a newly inited repo. Update the git prompt to support repos with git reftables. Bump actions/checkout from 5 to 6 ⬆️ Update dependencies (git-for-windows v2.52.0.windows.1, clink v1.9.2, clink-completions v0.6.7)
This commit is contained in:
11
.github/dependabot.yml
vendored
11
.github/dependabot.yml
vendored
@@ -1,11 +1,10 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions" # See documentation for possible values
|
||||
# Enable version updates for GitHub Actions
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
labels:
|
||||
- "👆 Dependencies"
|
||||
- "🔄️ GitHub Actions"
|
||||
|
||||
29
.github/workflows/branches.yml
vendored
29
.github/workflows/branches.yml
vendored
@@ -19,10 +19,25 @@ jobs:
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
# Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0 # fetch all history for all branches and tags
|
||||
|
||||
- name: Summary - Merge operation started
|
||||
shell: bash
|
||||
run: |
|
||||
echo "## 🔀 Update Branches - Workflow Summary" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "### Merge Operation" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Property | Value |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| --- | --- |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Source Branch | \`master\` |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Target Branch | \`development\` |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Triggered by | @${{ github.actor }} |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Commit | \`${{ github.sha }}\` |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
# Runs a single command using the runners shell
|
||||
- name: Merge master into development
|
||||
run: |
|
||||
@@ -31,3 +46,15 @@ jobs:
|
||||
git checkout development
|
||||
git merge --no-ff master
|
||||
git push origin development
|
||||
|
||||
- name: Summary - Merge completed
|
||||
if: success()
|
||||
shell: bash
|
||||
run: |
|
||||
echo "### ✅ Merge Successful" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "The \`master\` branch has been successfully merged into \`development\`." >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "**Merge type:** No fast-forward merge" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "> The development branch is now synchronized with the latest changes from master." >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
82
.github/workflows/build.yml
vendored
82
.github/workflows/build.yml
vendored
@@ -35,10 +35,25 @@ jobs:
|
||||
discussions: write
|
||||
steps:
|
||||
- name: Check out repository code (Action from GitHub)
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Summary - Repository checkout
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "## 📦 Build Cmder - Workflow Summary" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "### Repository Information" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| Property | Value |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| --- | --- |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| Repository | \`${{ github.repository }}\` |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| Branch | \`${{ github.ref_name }}\` |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| Commit | \`${{ github.sha }}\` |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| Actor | @${{ github.actor }} |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| Workflow | \`${{ github.workflow }}\` |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
|
||||
- name: Add MSBuild to PATH
|
||||
uses: microsoft/setup-msbuild@v2
|
||||
|
||||
@@ -47,6 +62,15 @@ jobs:
|
||||
working-directory: scripts
|
||||
run: .\build.ps1 -Compile -verbose -terminal all
|
||||
|
||||
- name: Summary - Build completed
|
||||
if: success()
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "### ✅ Build Status" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "Cmder launcher successfully compiled." >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
|
||||
- name: Pack the built files
|
||||
shell: pwsh
|
||||
working-directory: scripts
|
||||
@@ -92,31 +116,64 @@ jobs:
|
||||
path: build/cmder_wt_mini.zip
|
||||
name: cmder_wt_mini.zip
|
||||
|
||||
- name: Summary - Package artifacts
|
||||
if: success()
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "### 📦 Artifacts Created" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| Artifact | Size | Hash (SHA256) |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| --- | --- | --- |" >> $env:GITHUB_STEP_SUMMARY
|
||||
$artifacts = @("cmder.zip", "cmder.7z", "cmder_mini.zip")
|
||||
foreach ($artifact in $artifacts) {
|
||||
$path = "build/$artifact"
|
||||
if (Test-Path $path) {
|
||||
$size = (Get-Item $path).Length / 1MB
|
||||
# Truncate hash to first 16 chars for summary readability (full hash in hashes.txt)
|
||||
$hash = (Get-FileHash $path -Algorithm SHA256).Hash.Substring(0, 16)
|
||||
echo "| \`$artifact\` | $([math]::Round($size, 2)) MB | \`$hash...\` |" >> $env:GITHUB_STEP_SUMMARY
|
||||
}
|
||||
}
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
|
||||
- name: Upload artifact (cmder.zip)
|
||||
uses: actions/upload-artifact@v5
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
path: build/cmder.zip
|
||||
name: cmder.zip
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Upload artifact (cmder.7z)
|
||||
uses: actions/upload-artifact@v5
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
path: build/cmder.7z
|
||||
name: cmder.7z
|
||||
|
||||
- name: Upload artifact (cmder_mini.zip)
|
||||
uses: actions/upload-artifact@v5
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
path: build/cmder_mini.zip
|
||||
name: cmder_mini.zip
|
||||
|
||||
- name: Upload artifact (hashes.txt)
|
||||
uses: actions/upload-artifact@v5
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
path: build/hashes.txt
|
||||
name: hashes.txt
|
||||
|
||||
- name: Summary - Artifacts uploaded
|
||||
if: success()
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "### ☁️ Upload Status" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "All artifacts successfully uploaded to GitHub Actions:" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "- ✅ \`cmder.zip\`" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "- ✅ \`cmder.7z\`" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "- ✅ \`cmder_mini.zip\`" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "- ✅ \`hashes.txt\`" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
@@ -131,3 +188,18 @@ jobs:
|
||||
draft: true
|
||||
generate_release_notes: true
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
|
||||
- name: Summary - Release created
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "### 🚀 Release Information" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "Draft release created for tag: **\`${{ github.ref_name }}\`**" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "Release includes:" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "- Full version (\`cmder.zip\`, \`cmder.7z\`)" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "- Mini version (\`cmder_mini.zip\`)" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "- File hashes (\`hashes.txt\`)" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "> ⚠️ Release is in **draft** mode. Please review and publish manually." >> $env:GITHUB_STEP_SUMMARY
|
||||
|
||||
38
.github/workflows/codeql.yml
vendored
38
.github/workflows/codeql.yml
vendored
@@ -45,7 +45,22 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Summary - CodeQL analysis started
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "## 🔒 CodeQL Security Analysis - Workflow Summary" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "### Analysis Configuration" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| Property | Value |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| --- | --- |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| Repository | \`${{ github.repository }}\` |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| Branch | \`${{ github.ref_name }}\` |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| Language | \`${{ matrix.language }}\` |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| Commit | \`${{ github.sha }}\` |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
@@ -67,7 +82,28 @@ jobs:
|
||||
working-directory: scripts
|
||||
run: .\build.ps1 -Compile -verbose
|
||||
|
||||
- name: Summary - Build status
|
||||
if: success()
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "### ✅ Build Completed" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "Cmder launcher built successfully for CodeQL analysis." >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v4
|
||||
with:
|
||||
category: "/language:${{matrix.language}}"
|
||||
|
||||
- name: Summary - Analysis completed
|
||||
if: success()
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "### 🔍 CodeQL Analysis Results" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "✅ CodeQL security analysis completed successfully." >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "**Language analyzed:** \`${{ matrix.language }}\`" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "> Check the Security tab for detailed findings and recommendations." >> $env:GITHUB_STEP_SUMMARY
|
||||
|
||||
63
.github/workflows/tests.yml
vendored
63
.github/workflows/tests.yml
vendored
@@ -38,17 +38,78 @@ jobs:
|
||||
continue-on-error: false
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Summary - Test execution started
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "## 🧪 Run Tests - Workflow Summary" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "### Test Environment" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| Property | Value |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| --- | --- |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| Repository | \`${{ github.repository }}\` |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| Branch | \`${{ github.ref_name }}\` |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| Commit | \`${{ github.sha }}\` |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| Runner OS | \`${{ runner.os }}\` |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
|
||||
- name: Initialize vendors
|
||||
shell: pwsh
|
||||
working-directory: scripts
|
||||
run: .\build.ps1 -verbose
|
||||
|
||||
- name: Summary - Vendor initialization
|
||||
if: success()
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "### ⚙️ Vendor Initialization" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "✅ Vendor dependencies initialized successfully." >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
|
||||
- name: Summary - Test results table header
|
||||
if: success()
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "### 📋 Test Results" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| Test | Status |" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "| --- | --- |" >> $env:GITHUB_STEP_SUMMARY
|
||||
|
||||
- name: Testing Clink Shell
|
||||
run: |
|
||||
cmd /c vendor\init.bat /v /d /t
|
||||
|
||||
- name: Summary - Clink Shell test
|
||||
if: success()
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "| Clink Shell | ✅ Passed |" >> $env:GITHUB_STEP_SUMMARY
|
||||
- name: Testing PowerShell
|
||||
run: |
|
||||
PowerShell.exe -ExecutionPolicy Bypass -NoLogo -NoProfile -Command "$env:CMDER_DEBUG='1'; . 'vendor\profile.ps1'"
|
||||
|
||||
- name: Summary - PowerShell test
|
||||
if: success()
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "| PowerShell | ✅ Passed |" >> $env:GITHUB_STEP_SUMMARY
|
||||
- name: Testing Bash
|
||||
run: |
|
||||
bash vendor/cmder.sh
|
||||
|
||||
- name: Summary - Bash test
|
||||
if: success()
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "| Bash | ✅ Passed |" >> $env:GITHUB_STEP_SUMMARY
|
||||
|
||||
- name: Summary - All tests completed
|
||||
if: success()
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "### ✅ All Tests Completed" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "All shell environments tested successfully!" >> $env:GITHUB_STEP_SUMMARY
|
||||
|
||||
44
.github/workflows/vendor.yml
vendored
44
.github/workflows/vendor.yml
vendored
@@ -24,10 +24,18 @@ jobs:
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Summary - Workflow started
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "## 📦 Update Vendor - Workflow Summary" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "Checking for vendor dependency updates..." >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
|
||||
- id: make-changes
|
||||
name: Checking for updates
|
||||
env:
|
||||
@@ -51,7 +59,25 @@ jobs:
|
||||
Set-GHVariable -Name LIST_UPDATED -Value $listUpdated.Trim(', ')
|
||||
echo "UPDATE_MESSAGE<<<EOF`n$updateMessage`n<EOF" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
|
||||
- uses: peter-evans/create-pull-request@v7
|
||||
- name: Summary - Update check results
|
||||
shell: pwsh
|
||||
run: |
|
||||
$count = $env:COUNT_UPDATED
|
||||
if ($count -eq 0) {
|
||||
echo "### ✅ No Updates Available" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "All vendor dependencies are up to date." >> $env:GITHUB_STEP_SUMMARY
|
||||
} else {
|
||||
$word = if ($count -eq 1) { 'dependency' } else { 'dependencies' }
|
||||
echo "### 🔄 Updates Found" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "**$count** vendor $word updated:" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "$env:UPDATE_MESSAGE" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
}
|
||||
|
||||
- uses: peter-evans/create-pull-request@v8
|
||||
if: env.COUNT_UPDATED > 0
|
||||
with:
|
||||
title: 'Updates to `${{ env.COUNT_UPDATED }}` vendored dependencies'
|
||||
@@ -63,3 +89,17 @@ jobs:
|
||||
commit-message: '⬆️ Update dependencies (${{ env.LIST_UPDATED }})'
|
||||
branch: update-vendor
|
||||
base: master
|
||||
|
||||
- name: Summary - Pull request created
|
||||
if: env.COUNT_UPDATED > 0
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "### 🎉 Pull Request Created" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "A pull request has been created to update the vendor dependencies." >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "**Branch:** \`update-vendor\`" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "**Updated dependencies:** $env:LIST_UPDATED" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "" >> $env:GITHUB_STEP_SUMMARY
|
||||
echo "> Please review and merge the pull request to apply the updates." >> $env:GITHUB_STEP_SUMMARY
|
||||
|
||||
116
vendor/clink.lua
vendored
116
vendor/clink.lua
vendored
@@ -324,7 +324,7 @@ end
|
||||
-- Find out current branch
|
||||
-- @return {nil|git branch name}
|
||||
---
|
||||
local function get_git_branch(git_dir)
|
||||
local function get_git_branch(git_dir, fast)
|
||||
git_dir = git_dir or get_git_dir()
|
||||
|
||||
-- If git directory not found then we're probably outside of repo
|
||||
@@ -341,8 +341,90 @@ local function get_git_branch(git_dir)
|
||||
-- if HEAD matches branch expression, then we're on named branch
|
||||
-- otherwise it is a detached commit
|
||||
local branch_name = HEAD:match('ref: refs/heads/(.+)')
|
||||
if os.getenv("CLINK_DEBUG_GIT_REFTABLE") then
|
||||
branch_name = '.invalid'
|
||||
end
|
||||
|
||||
return branch_name or 'HEAD detached at '..HEAD:sub(1, 7)
|
||||
-- If the branch name is ".invalid" and the fast method wasn't requested,
|
||||
-- then invoke git.exe to get accurate current branch info (slow method).
|
||||
if branch_name == ".invalid" and not fast then
|
||||
local file
|
||||
branch_name = nil
|
||||
|
||||
-- Handle the most common case first.
|
||||
if not branch_name then
|
||||
file = io_popenyield("git --no-optional-locks branch 2>nul")
|
||||
if file then
|
||||
for line in file:lines() do
|
||||
local b = line:match("^%*%s+(.*)")
|
||||
if b then
|
||||
b = b:match("^%((HEAD detached at .*)%)") or b
|
||||
branch_name = b
|
||||
break
|
||||
end
|
||||
end
|
||||
file:close()
|
||||
end
|
||||
end
|
||||
|
||||
-- Handle the cases where "git branch" output is empty, but "git
|
||||
-- branch --show-current" shows the branch name (e.g. a new repo).
|
||||
if not branch_name then
|
||||
file = io_popenyield("git --no-optional-locks branch --show-current 2>nul")
|
||||
if file then
|
||||
for line in file:lines() do -- luacheck: ignore 512
|
||||
branch_name = line
|
||||
break
|
||||
end
|
||||
file:close()
|
||||
end
|
||||
end
|
||||
else
|
||||
branch_name = branch_name or 'HEAD detached at '..HEAD:sub(1, 7)
|
||||
end
|
||||
|
||||
return branch_name
|
||||
end
|
||||
|
||||
local function get_git_remote(git_dir, branch)
|
||||
if not git_dir then return nil end
|
||||
if not branch then return nil end
|
||||
|
||||
local file = io.open(git_dir.."/config", 'r')
|
||||
if not file then return nil end
|
||||
|
||||
local git_config = {}
|
||||
|
||||
local function get_git_config_value(section, param)
|
||||
return git_config[section] and git_config[section][param] or nil
|
||||
end
|
||||
|
||||
local section
|
||||
for line in file:lines() do
|
||||
if (line:sub(1,1) == "[" and line:sub(-1) == "]") then
|
||||
if (line:sub(2,5) == "lfs ") then
|
||||
section = nil -- skip LFS entries as there can be many and we never use them
|
||||
else
|
||||
section = line:sub(2,-2)
|
||||
git_config[section] = git_config[section] or {}
|
||||
end
|
||||
elseif section then
|
||||
local param, value = line:match('^%s-([%w|_]+)%s-=%s+(.+)$')
|
||||
if (param and value ~= nil) then
|
||||
git_config[section][param] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
file:close()
|
||||
|
||||
local remote_to_push = get_git_config_value('branch "'..branch..'"', 'remote') or ''
|
||||
local remote_ref = get_git_config_value('remote "'..remote_to_push..'"', 'push') or
|
||||
get_git_config_value('push', 'default')
|
||||
|
||||
local text = remote_to_push
|
||||
if remote_ref then text = text..'/'..remote_ref end
|
||||
|
||||
return text ~= '' and text or nil
|
||||
end
|
||||
|
||||
---
|
||||
@@ -394,7 +476,7 @@ end
|
||||
-- Get the status and conflict status of working dir
|
||||
-- @return {bool <status>, bool <is_conflict>}
|
||||
---
|
||||
local function get_git_status()
|
||||
local function get_git_status(git_dir)
|
||||
local file = io_popenyield("git --no-optional-locks status --porcelain 2>nul")
|
||||
if not file then
|
||||
return {}
|
||||
@@ -416,7 +498,10 @@ local function get_git_status()
|
||||
end
|
||||
file:close()
|
||||
|
||||
return { status = is_status, conflict = conflict_found }
|
||||
local branch = get_git_branch(git_dir, false--[[fast]])
|
||||
local remote = get_git_remote(git_dir, branch)
|
||||
|
||||
return { status = is_status, branch = branch, remote = remote, conflict = conflict_found }
|
||||
end
|
||||
|
||||
---
|
||||
@@ -515,11 +600,11 @@ end
|
||||
-- Use a prompt coroutine to get git status in the background.
|
||||
-- Cache the info so we can reuse it next time to reduce flicker.
|
||||
---
|
||||
local function get_git_info_table()
|
||||
local function get_git_info_table(git_dir)
|
||||
local info = clink_promptcoroutine(function ()
|
||||
-- Use git status if allowed.
|
||||
local cmderGitStatusOptIn = get_git_status_setting()
|
||||
return cmderGitStatusOptIn and get_git_status() or {}
|
||||
return cmderGitStatusOptIn and get_git_status(git_dir) or {}
|
||||
end)
|
||||
if not info then
|
||||
info = cached_info.git_info or {}
|
||||
@@ -539,10 +624,11 @@ local function git_prompt_filter()
|
||||
local git_dir = get_git_dir()
|
||||
local color
|
||||
if git_dir then
|
||||
local branch = get_git_branch(git_dir)
|
||||
local branch = get_git_branch(git_dir, true--[[fast]])
|
||||
if branch then
|
||||
-- If in a different repo or branch than last time, discard cached info.
|
||||
if cached_info.git_dir ~= git_dir or cached_info.git_branch ~= branch then
|
||||
if cached_info.git_dir ~= git_dir or
|
||||
(branch ~= ".invalid" and cached_info.git_branch ~= branch) then
|
||||
cached_info.git_info = nil
|
||||
cached_info.git_dir = git_dir
|
||||
cached_info.git_branch = branch
|
||||
@@ -550,10 +636,22 @@ local function git_prompt_filter()
|
||||
|
||||
-- If we're inside of git repo then try to detect current branch
|
||||
-- Has branch => therefore it is a git folder, now figure out status
|
||||
local gitInfo = get_git_info_table()
|
||||
local gitInfo = get_git_info_table(git_dir)
|
||||
local gitStatus = gitInfo.status
|
||||
local gitConflict = gitInfo.conflict
|
||||
|
||||
-- Compensate for git reftables.
|
||||
branch = gitInfo.branch or branch
|
||||
if branch == ".invalid" then
|
||||
branch = "Loading..."
|
||||
elseif gitInfo.remote then
|
||||
branch = branch.." -> "..gitInfo.remote
|
||||
end
|
||||
|
||||
-- Prevent an older clink-completions git_prompt.lua scripts from
|
||||
-- modifying the prompt.
|
||||
branch = "\x1b[10m"..branch
|
||||
|
||||
if gitStatus == nil then
|
||||
color = get_unknown_color()
|
||||
elseif gitStatus then
|
||||
|
||||
12
vendor/sources.json
vendored
12
vendor/sources.json
vendored
@@ -1,13 +1,13 @@
|
||||
[
|
||||
{
|
||||
"name": "git-for-windows",
|
||||
"version": "2.51.2.windows.1",
|
||||
"url": "https://github.com/git-for-windows/git/releases/download/v2.51.2.windows.1/PortableGit-2.51.2-64-bit.7z.exe"
|
||||
"version": "2.52.0.windows.1",
|
||||
"url": "https://github.com/git-for-windows/git/releases/download/v2.52.0.windows.1/PortableGit-2.52.0-64-bit.7z.exe"
|
||||
},
|
||||
{
|
||||
"name": "clink",
|
||||
"version": "1.8.8",
|
||||
"url": "https://github.com/chrisant996/clink/releases/download/v1.8.8/clink.1.8.8.a63364.zip"
|
||||
"version": "1.9.5",
|
||||
"url": "https://github.com/chrisant996/clink/releases/download/v1.9.5/clink.1.9.5.ee6b4f.zip"
|
||||
},
|
||||
{
|
||||
"name": "conemu-maximus5",
|
||||
@@ -21,7 +21,7 @@
|
||||
},
|
||||
{
|
||||
"name": "clink-completions",
|
||||
"version": "0.6.6",
|
||||
"url": "https://github.com/vladimir-kotikov/clink-completions/archive/v0.6.6.zip"
|
||||
"version": "0.6.7",
|
||||
"url": "https://github.com/vladimir-kotikov/clink-completions/archive/v0.6.7.zip"
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user