My team (20p) is moving to Fibery (from notion). I’d like to have more details coming from the gitlab integration, especially diff stats. First for MR, maybe later for commits.
This would help us to track which MR have increased code size, which are cleanup, who contributes to refactoring, evaluate code churn …
Thanks for the feedback. We will add additional feature to our backlog to include mentioned details for MR. Not sure about exact dates of implementation.
In case you would like to have it ASAP then the automation can be used to retrieve this info: script action can be used to retrieve it from gitlab invoked by rule on MR created. You can find more info here Fibery API
Thanks @Oleg ! I’ve been trying to implement the suggested workaround but I need help to finish it - see comments in my code below for the details.
I could test the first steps with a Button and Chrome developper tools following other tutorials found on your site, a basic call to Gitlab works fine.
const fibery = context.getService('fibery');
const http = context.getService('http');
const url = 'https://gitlab.com/api/graphql'
for (const mr of args.currentEntities) {
const id = mr['Public Id']; // Extracted via a regex from the URL field
// I need help here to retrieve the full path following the relation between MergeRequest and Project (coming from Gitlab integration)
// (I don't get how this example would be adapted : const entityWithExtraFields = await fibery.getEntityById(mr.type, mr.id, ['Assignees', 'Files']);
)
const req =JSON.stringify({
query: `{
project(fullPath: \"${projectPath}\") {
name
mergeRequest(iid: \"${id}\") {
id
diffStatsSummary {
additions
changes
fileCount
deletions
}
}
}
}`, });
console.log(req);
// is there a safe way to pass the token here ? And to store it in only one place for future automations ?
const response = await http.postAsync(url, {
headers: {
'Authorization': 'Bearer MYTOKEN',
'Content-Type': 'application/json',
},
body: req
});
console.log(response); // works when field are hardcoded
// I'd like an example here to update the entity based on data coming from graphQL
}
Also en example of update can be found in script action itself:
for (const entity of args.currentEntities) {
// to update an entity provide an object with the new values
await fibery.updateEntity(entity.type, entity.id, {
'Field Name': newValue
});
}