Add app-specific git repo view with push instructions
This commit is contained in:
parent
2046af1407
commit
35341600c1
|
|
@ -503,11 +503,88 @@ app.on('POST', ['/:repo{.+\\.git}/git-receive-pack', '/:repo/git-receive-pack'],
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get('/', async c => {
|
app.get('/', async c => {
|
||||||
const repos = await listRepos()
|
const appName = c.req.query('app')
|
||||||
const host = c.req.header('host') ?? 'git.toes.local'
|
const host = c.req.header('host') ?? 'git.toes.local'
|
||||||
|
|
||||||
const baseUrl = `http://${host}`
|
const baseUrl = `http://${host}`
|
||||||
|
|
||||||
|
// When viewing a specific app, only show that app's repo
|
||||||
|
if (appName) {
|
||||||
|
const bare = repoPath(appName)
|
||||||
|
const exists = await dirExists(bare)
|
||||||
|
const [commits, branch] = exists
|
||||||
|
? await Promise.all([hasCommits(bare), getDefaultBranch(bare)])
|
||||||
|
: [false, 'main']
|
||||||
|
|
||||||
|
return c.html(
|
||||||
|
<Layout title={`Git - ${appName}`}>
|
||||||
|
{exists && commits ? (
|
||||||
|
<>
|
||||||
|
<Heading>Repository</Heading>
|
||||||
|
<RepoList>
|
||||||
|
<RepoItem>
|
||||||
|
<div>
|
||||||
|
<RepoName>{appName}</RepoName>
|
||||||
|
<HelpText style="margin: 4px 0 0; font-size: 12px">
|
||||||
|
git clone {baseUrl}/{appName}.git
|
||||||
|
</HelpText>
|
||||||
|
</div>
|
||||||
|
<div style="display: flex; gap: 8px; align-items: center">
|
||||||
|
<Badge>{branch}</Badge>
|
||||||
|
<Badge style={`color: ${theme('colors-statusRunning')}`}>deployed</Badge>
|
||||||
|
</div>
|
||||||
|
</RepoItem>
|
||||||
|
</RepoList>
|
||||||
|
|
||||||
|
<Heading>Push Changes</Heading>
|
||||||
|
<CodeBlock>{[
|
||||||
|
`git push toes ${branch}`,
|
||||||
|
'',
|
||||||
|
'# Or if remote not yet added:',
|
||||||
|
`git remote add toes ${baseUrl}/${appName}.git`,
|
||||||
|
`git push toes ${branch}`,
|
||||||
|
].join('\n')}</CodeBlock>
|
||||||
|
</>
|
||||||
|
) : exists ? (
|
||||||
|
<>
|
||||||
|
<Heading>Repository</Heading>
|
||||||
|
<RepoList>
|
||||||
|
<RepoItem>
|
||||||
|
<div>
|
||||||
|
<RepoName>{appName}</RepoName>
|
||||||
|
<HelpText style="margin: 4px 0 0; font-size: 12px">
|
||||||
|
git clone {baseUrl}/{appName}.git
|
||||||
|
</HelpText>
|
||||||
|
</div>
|
||||||
|
<Badge>empty</Badge>
|
||||||
|
</RepoItem>
|
||||||
|
</RepoList>
|
||||||
|
|
||||||
|
<Heading>Push to Deploy</Heading>
|
||||||
|
<CodeBlock>{[
|
||||||
|
`git remote add toes ${baseUrl}/${appName}.git`,
|
||||||
|
'git push toes main',
|
||||||
|
].join('\n')}</CodeBlock>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Heading>Push to Deploy</Heading>
|
||||||
|
<HelpText>
|
||||||
|
No git repository for <strong>{appName}</strong> yet.
|
||||||
|
Push to create one and deploy.
|
||||||
|
</HelpText>
|
||||||
|
<CodeBlock>{[
|
||||||
|
`git remote add toes ${baseUrl}/${appName}.git`,
|
||||||
|
'git push toes main',
|
||||||
|
].join('\n')}</CodeBlock>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Layout>,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// No app selected — show all repos
|
||||||
|
const repos = await listRepos()
|
||||||
|
|
||||||
const repoData = await Promise.all(repos.map(async name => {
|
const repoData = await Promise.all(repos.map(async name => {
|
||||||
const bare = repoPath(name)
|
const bare = repoPath(name)
|
||||||
const [commits, branch] = await Promise.all([hasCommits(bare), getDefaultBranch(bare)])
|
const [commits, branch] = await Promise.all([hasCommits(bare), getDefaultBranch(bare)])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user