Skip to content

Commit

Permalink
perf: unshallow with a filter
Browse files Browse the repository at this point in the history
when action runs, unshallow the repository with filter `blob:none`.

this should makes git only download commits histories from the server without
loading file contents.

should make the action faster when running with large repository
  • Loading branch information
tony84727 committed Aug 31, 2024
1 parent 8eb91f2 commit 6b6d74a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ export async function revParse(rev: string, cwd?: string): Promise<string> {
return output.trim()
}

export async function unshallow(): Promise<number> {
return exec('git', ['fetch', '--prune', '--unshallow'])
export async function unshallowHistories(): Promise<number> {
return exec('git', ['fetch', '--prune', '--unshallow', '--filter=blob:none'])
}
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as core from '@actions/core'
import {Rule, parseRules} from './rule'
import {getChangedFiles, revParse, unshallow} from './git'
import {getChangedFiles, revParse, unshallowHistories} from './git'
import {newGlobber} from './glob'
function evaluateRule(rule: Rule, changedFiles: string[]): string[] {
const globber = newGlobber(rule.match)
Expand All @@ -25,7 +25,7 @@ async function getHeadSha(): Promise<string> {
async function run(): Promise<void> {
try {
const event = core.getInput('event')
await unshallow()
await unshallowHistories()
const baseSha = await getBaseSha(event)
const headSha = await getHeadSha()
core.debug(`baseSha: ${baseSha}`)
Expand Down

0 comments on commit 6b6d74a

Please sign in to comment.