repobee / repobee-sanitizer

A plugin for sanitizing master repositories before distribution to students
MIT License
2 stars 3 forks source link

Make it possible to strip a file of sanitizer stuff #92

Closed slarse closed 4 years ago

slarse commented 4 years ago

This possibly only makes sense for sanitize file. In any case, we must be able to remove all sanitizer blocks/markers from a file. For example, given the following file StackTest.java:

class StackTest {
    @Test
    public void topIsLastPushedValue() {
//REPOBEE-SANITIZER-START
        // Arrange
        int value = 1338;

        // Act
        emptyStack.push(value);
        stack.push(value);

        int emptyStackTop = emptyStack.top();
        int stackTop = stack.top();

        // Assert
        assertThat(emptyStackTop, equalTo(value));
        assertThat(stackTop, equalTo(value));
//REPOBEE-SANITIZER-REPLACE-WITH
//        fail("Not implemented");
//REPOBEE-SANITIZER-END
    }
}

I would like to be able to type something like this:

$ repobee sanitize file StackTest.java StackTestStripped.java --strip

And get a new file StackTestStripped.java with the following contents:

class StackTest {
    @Test
    public void topIsLastPushedValue() {
        // Arrange
        int value = 1338;

        // Act
        emptyStack.push(value);
        stack.push(value);

        int emptyStackTop = emptyStack.top();
        int stackTop = stack.top();

        // Assert
        assertThat(emptyStackTop, equalTo(value));
        assertThat(stackTop, equalTo(value));
    }
}

To be clear, markers should be removed as usual, but the logic in blocks should be reversed (i.e. keep the first part and remove any replace block).