Using jQAssistant with Git Plugin to determine changed files by author

35 Views Asked by At

I'm trying to build a query to list all files changed by an author (to later filter them by other information based on stereotypes).

Currently the query returns way to many files - probably due to merges (?)

My understanding of the Git / Graph Model is this:

enter image description here

The current query I use:

MATCH (author:Git:Author)-[:COMMITTED]->(commit:Git:Commit)-[cc:CONTAINS_CHANGE]->(change:Git:Change)-[]->(file:Git:File)
WHERE author.email="[email protected]"
RETURN file.relativePath
ORDER BY file.relativePath ASC

This returns way too many files. Some random samples I took a look at does not show that developer in the git history of that file. I assume this happens due to some merges?

The random sample shows that author of interest and some path to the file: enter image description here

But using the IDE to look into the git history of that file does not show the author in there.

Something that returns a list much closer to my expected result with git commands:

git log --no-merges --author="developer-of-interest" --name-only --pretty=format:"" | sort -u

Looking at the nodes and relations (yellow one points to the file I never touched) nothing looks like a hint to exclude that specific commit: enter image description here

I'm pretty sure the Neo4j query is somehow wrong?

How can I ignore those commits caused by merges? (if that is the issue)

I don't know how git log is able to filter out those commits but with jqassert and the git plugin that information seems to be lost?

1

There are 1 best solutions below

5
cybersam On

Maybe you just need to return distinct files:

MATCH (author:Git:Author)-[:COMMITTED]->(:Git:Commit)-[:CONTAINS_CHANGE]->(:Git:Change)-->(file:Git:File)
WHERE author.email="[email protected]"
WITH DISTINCT file
RETURN file.relativePath
ORDER BY file.relativePath ASC

Also, omit the :Git label from your query if that would return the same results. The query would run faster with less filtering.

In addition, if there are many types of relationships between Change and File nodes, perhaps some are not appropriate for you use case. If so, you should be specific about the desired relationship types.

Finally, there may be properties somewhere on matched paths that you need to use to filter out unwanted files.