big fixes
fixes feedback from thecodacus
This commit is contained in:
@@ -9,22 +9,30 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
try {
|
||||
// Get git information using git commands
|
||||
const branch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
|
||||
const commit = execSync('git rev-parse HEAD').toString().trim();
|
||||
const commitHash = execSync('git rev-parse HEAD').toString().trim();
|
||||
const commitTime = execSync('git log -1 --format=%cd').toString().trim();
|
||||
const author = execSync('git log -1 --format=%an').toString().trim();
|
||||
const email = execSync('git log -1 --format=%ae').toString().trim();
|
||||
const remoteUrl = execSync('git config --get remote.origin.url').toString().trim();
|
||||
|
||||
// Extract repo name from remote URL
|
||||
const repoName = remoteUrl.split('/').pop()?.replace('.git', '') || '';
|
||||
|
||||
const gitInfo = {
|
||||
branch,
|
||||
commit,
|
||||
commitTime,
|
||||
author,
|
||||
remoteUrl,
|
||||
local: {
|
||||
commitHash,
|
||||
branch,
|
||||
commitTime,
|
||||
author,
|
||||
email,
|
||||
remoteUrl,
|
||||
repoName,
|
||||
},
|
||||
};
|
||||
|
||||
res.status(200).json(gitInfo);
|
||||
return res.status(200).json(gitInfo);
|
||||
} catch (error) {
|
||||
console.error('Failed to get git information:', error);
|
||||
res.status(500).json({ message: 'Failed to get git information' });
|
||||
return res.status(500).json({ message: 'Failed to get git information' });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user