Skip to content

Local repository structure is not refreshed after git switches to a different tag with a different catalogue structure #10

@akoufoudakis

Description

@akoufoudakis

I have faced the following experience, trying to calculate the number of SLOCs, using Rascal and Rascal-git.

Background

When analyzing the Apache Commons Text: https://github.com/apache/commons-text.git, I am switching the tags.
However, when the catalogue structure is changed, the M3 model is not updated and the line counting returns 0 lines.
For example, the tag https://github.com/apache/commons-text/tree/commons-text-1.0-beta-1-RC4 has the following structure of the src catalogue: https://github.com/apache/commons-text/tree/commons-text-1.0-beta-1-RC4/src/main/java/org/apache/commons/text/beta.

The "next" (time wise) tag: https://github.com/apache/commons-text/tree/commons-text-1.0-RC1 has the following structure:
https://github.com/apache/commons-text/tree/commons-text-1.0-RC1/src/main/java/org/apache/commons/text.

When I run the following simple code:

module Main

import IO;
import lang::java::m3::Core;
import lang::java::m3::AST;
import lang::json::IO;
import util::FileSystem;
import util::git::Git;
import util::PathConfig;
import util::Reflective;
import util::ShellExec;
import util::UUID;
import List;
import Map;
import Set;
import String;
import UnitLocReader;
import Exception;
import Location;
import Message;
import AsfProject;

void main(int testArgument = 0) {
    loc repoRoot = |file:///Users/akoufoudakis/codebase/commons-text|;
        
    cloneRemoteRepository("https://github.com/apache/commons-text.git", repoRoot);

    list[str] tags = ["commons-text-1.0-beta-1-RC4", "commons-text-1.0-RC1"];
    for (tagIndex <- [0 .. size(tags)]) {
            
        println("Analyzing tag: <tags[tagIndex]>");
            
        switchToTag(repoRoot, tags[tagIndex]);
        exec("git", workingDir=repoRoot, args=["clean", "-fdx"]);

        M3 model = createM3FromDirectory(repoRoot); 
        set[loc] modelClasses = classes(model);
        int lineCount = size(getAllCodeLines(modelClasses));

            
        println("Total Lines for <tags[tagIndex]>: <lineCount>");
    }
}

I get the following results:

Analyzing tag: commons-text-1.0-beta-1-RC4
Total Lines for commons-text-1.0-beta-1-RC4: 12209
Analyzing tag: commons-text-1.0-RC1
Total Lines for commons-text-1.0-RC1: 0

I'm using the following versions:
Rascal: 0.42.1
Java air: 1.0.2
Rascal-git: 0.1.16
Rascal-maven-plugin: 0.31.0.
There is a workaround for it:

set[loc] javaFiles = { f | f <- files(repoRoot), f.extension == "java" };
list[str] totalLines = getAllCodeLines(javaFiles);

However, I am not sure that the behaviour, which I described, is a desired one.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions