Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/mcp-provider-devops/src/commitWorkItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ export async function commitWorkItem({
.split('\n').map(l => l.trim()).filter(Boolean);
const untrackedRel = execFileSync('git', ['ls-files', '--others', '--exclude-standard'], { cwd: workingDir, encoding: 'utf8' })
.split('\n').map(l => l.trim()).filter(Boolean);
const stagedRel = execFileSync('git', ['diff', '--cached', '--name-only'], { cwd: workingDir, encoding: 'utf8' })
.split('\n').map(l => l.trim()).filter(Boolean);



Expand All @@ -135,6 +137,11 @@ export async function commitWorkItem({
if (isModified) operation = 'modify';
}

if (!operation) {
const isStaged = stagedRel.some(p => isMatch(fileName, p));
if (isStaged) operation = 'modify';
}

if (operation && componentType) {
computedChanges.push({ fullName, type: componentType, operation });
}
Expand Down
65 changes: 42 additions & 23 deletions packages/mcp-provider-devops/src/getCommitStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,51 @@ export interface CommitStatusResult {
}

export async function fetchCommitStatus(username: string, requestId: string): Promise<CommitStatusResult> {
if (!username || username.trim().length === 0) {
throw new Error('Username is required. Please provide the DevOps Center org username.');
}

const connection = await getConnection(username);
const query = `SELECT Id, Status__c, RequestToken__c FROM DevopsRequestInfo WHERE RequestToken__c = '${requestId}' LIMIT 1`;

const response = await axios.get(`${connection.instanceUrl}/services/data/v65.0/query`, {
headers: {
'Authorization': `Bearer ${connection.accessToken}`,
'Content-Type': 'application/json'
},
params: { q: query }
});

if (response.data.records && response.data.records.length > 0) {
const record = response.data.records[0];
return {
requestId,
status: record.Status__c,
recordId: record.Id,
message: `Request ${requestId} has status: ${record.Status__c}`
};
const accessToken = connection.accessToken;
const instanceUrl = connection.instanceUrl;

if (!accessToken || !instanceUrl) {
throw new Error('Missing access token or instance URL. Please check if you are authenticated to the org.');
}

if (!requestId || requestId.trim().length === 0) {
throw new Error('Request ID is required to check commit status.');
}

return {
requestId,
status: 'NOT_FOUND',
message: `No record found for request ID: ${requestId}`
const soqlQuery = `SELECT Status FROM DevopsRequestInfo WHERE RequestToken = '${requestId}'`;
const encodedQuery = encodeURIComponent(soqlQuery);
const url = `${instanceUrl}/services/data/v65.0/query/?q=${encodedQuery}`;
const headers = {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
};
}

try {
const response = await axios.get(url, { headers });
const records = response.data.records || [];

if (records.length === 0) {
return {
requestId,
status: 'NOT_FOUND',
message: `No commit status found for request ID: ${requestId}`
};
}

const status = records[0].Status;
return {
requestId,
status,
recordId: records[0].Id,
message: `Commit status for request ID ${requestId}: ${status}`
};
} catch (error: any) {
const errorMessage = error.response?.data?.[0]?.message || error.message;
throw new Error(`Error checking commit status: ${errorMessage}`);
}
}
Loading