Skip to content

Commit edf9275

Browse files
dennisamelingdscho
authored andcommitted
git: export useful functionality
In the upcoming commit, we will implement support for removing the SDK files in a post-action step. To this end, we need access to Git for Windows' `bash` (if it exists on the agent) and to the default location of the SDK that is written by this Action. Let's export those to allow for reusing the functionality in other source files. Signed-off-by: Dennis Ameling <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent e79135e commit edf9275

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/git.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {Octokit} from '@octokit/rest'
44
import {delimiter} from 'path'
55
import * as fs from 'fs'
66

7-
const gitForWindowsUsrBinPath = 'C:/Program Files/Git/usr/bin'
7+
export const gitForWindowsUsrBinPath = 'C:/Program Files/Git/usr/bin'
88
const gitExePath = 'C:/Program Files/Git/cmd/git.exe'
99

1010
/*
@@ -18,6 +18,17 @@ const gitExePath = 'C:/Program Files/Git/cmd/git.exe'
1818
*/
1919
const GIT_CONFIG_PARAMETERS = `'checkout.workers=56'`
2020

21+
export function getArtifactMetadata(
22+
flavor: string,
23+
architecture: string
24+
): {bitness: string; repo: string; artifactName: string} {
25+
const bitness = architecture === 'i686' ? '32' : '64'
26+
const repo = `git-sdk-${bitness}`
27+
const artifactName = `${repo}-${flavor}`
28+
29+
return {bitness, repo, artifactName}
30+
}
31+
2132
async function clone(
2233
url: string,
2334
destination: string,
@@ -65,10 +76,12 @@ export async function getViaGit(
6576
verbose?: number | boolean
6677
) => Promise<void>
6778
}> {
68-
const bitness = architecture === 'i686' ? '32' : '64'
6979
const owner = 'git-for-windows'
70-
const repo = `git-sdk-${bitness}`
71-
const artifactName = `${repo}-${flavor}`
80+
81+
const {bitness, repo, artifactName} = getArtifactMetadata(
82+
flavor,
83+
architecture
84+
)
7285

7386
const octokit = new Octokit()
7487
let head_sha: string

0 commit comments

Comments
 (0)