Giter Club home page Giter Club logo

Comments (4)

connorferster avatar connorferster commented on May 25, 2024 1

Holy smokes, @rjglasse! I really appreciate that. It saves me a good couple of hours of faffing around trying to figure out where to start.

from repobee.

rjglasse avatar rjglasse commented on May 25, 2024

Hi Connor,

Not at present with the default commands.

However, Repobee was designed with a plugin architecture that allows you to extend it to fit your context. Here's the documentation: https://docs.repobee.org/en/stable/repobee_plug/index.html#repobee-plug - it has some nice examples to help you get started.

I guess you want to have a plugin that uses a post-clone hook to check if the latest commit author matches the prefix of the repo. A more robust alternative would test that the commit author is not one of the repo template authors / teachers, where there may be multiple student usernames in a single repo, or a single student is managing to use multiple identities.

Here's a bit of Python/Bash that will grab the username, assuming you are in the repo's directory.

import subprocess
author = subprocess.check_output("git log -1 --pretty=format:'%an'", shell=True)
print(author.decode("utf-8").lower())

There might be a smarter Repobee way to get the last commit author (@slarse?)

Let us know if you want to have a bash at it, or perhaps we can whip one up :)

from repobee.

rjglasse avatar rjglasse commented on May 25, 2024

Alright, this is my first actual attempt at a plugin (started.py), but I like the use case so win-win for me. Here's something that works, but probably needs some improvement:

import repobee_plug as plug
import subprocess
import os

@plug.repobee_hook
def post_clone(repo: plug.StudentRepo, api: plug.PlatformAPI):
    os.chdir(repo.path)
    last_commit_author = subprocess.check_output("git log -1 --pretty=format:'%an'", shell=True).decode("utf-8").strip().lower()
    teachers = ["glassey"]
    if last_commit_author in teachers:
        print("[Repo Status]", repo.name, "has no student activity. The last commit was made by", last_commit_author)

And the trace would look like this for a known non participating student, and silent if student has started:

% repobee -p started.py  repos clone -a task-1 -s xxxx --update-local 
Cloning into student repos ...
Progress batch 1: 100%
Executing post_clone hooks:
[Repo Status] xxxx-task-1 has no student activity. The last commit was made by glassey
Executing post_clone hooks: 100%

Probably smart to export to file, JSON or CSV if you have a lot of students :-)

from repobee.

slarse avatar slarse commented on May 25, 2024

This is indeed a very good use case for a plugin, thanks @rjglasse for providing a prototype!

There might be a smarter Repobee way to get the last commit author (@slarse?)

Nope, RepoBee doesn't deal with commits at present. However, GitPython provides a pretty nice Python interface to Git, I'd probably use that for better ergonomics. I think I use it somewhere in RepoBee but I forget where at the moment, but a plugin is free to have any dependencies it likes to as long as they don't conflict with the core dependencies (which is why I try to keep the amount of core dependencies tiny).

from repobee.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.