Giter Club home page Giter Club logo

gh-org-commits's Introduction

gh extension for GitHub CLI gh org-commits

Get the commits of the students for a GitHub Classroom assignment for a specified date range.

Installation

gh extension install gh-cli-for-education/gh-org-commits

Usage

✗ gh org-commits --help
USAGE
  gh-org-commits [options]
Available options:
  -o --ORG <GitHub Organization>
  -l --lab <gh classroom assignment>
  -d --day <yyyy-mm-dd>
  -f --file <file with students>
  -b --begin <HH:MM:SS>
  -e --end <HH:MM:SS>
  -z --timezone [timezone]
  -t --total
Example:
  gh org-commits -o "my-org" -l "lab-1" -d "2020-09-01" -f "students.txt" -b "00:00:00" -e "23:59:59" -z "Z"

Defaults

ORG

By default the ORG is obtained using the output of command gh pwd. For a better experience:

  set alias pwd to:  !gh config get current-org
  set alias cd to:   !gh config set current-org "$1" 2>/dev/null

lab

the default lab is set to the output of the command gh pwd-lab

  set alias cd-lab to:   !gh config set current-lab "$1" 2>/dev/null  
  set alias pwd-lab to:  !gh config get current-lab

begin

00:00:00

end

23:59:59

day

Start day. The reported commits will be from this day to today.

file

_data/team-names.txt

total

The output json is simplified as an array in which only the repo lab and the total number of commits is shown:

[
  {
    "name": "aprender-markdown-alejandro-febles-casquero-alu0101013282",
    "total": 7
  },
  {
    "name": "aprender-markdown-alejandro-sanchez-alu0100086393",
    "total": 6
  },
  ...
]

Example

You must create a file with the students names, one per line, and use it as input for the command. An easy way to create it is with the extension org-teams-names:

✗ gh org-teams-names --org ULL-ESIT-PL-2223 | head -4
adal-diaz-farinya-alu0101112251
adrian-fleitas-de_la_rosa-alu0101024363
adriano-dos_santos-alu0101436784
adrian_grassin-luis-alu0101349480
...

Given this team names file:

    ➜  apuntes git:(main) ✗ cat _data/team-names.txt 
    "miguel-rodriguez-caputo-alu0100708974"
    # comments and empty lines are ignored
    #"luis-fernando-fernandez-alu0101232775"
    "maria-Suarez-alu0101232775"
    #"maria-fernanda-fernandez-alu0101232775"

the following command

✗ gh org-teams-names --org ULL-MFP-AET-2223 > /tmp/aet-teams

Creates the file /tmp/aet-teams with the team names and the command

✗ gh org-commits -f /tmp/aet-teams \
             -d '2022-10-27' \
             -l 'aprender-markdown'  \
             -o ULL-MFP-AET-2223 > /tmp/commits-for-aprender-markdown.json

Produces warnings for the students that have not created the repository yet:

gh: Could not resolve to a Repository with the name 'ULL-MFP-AET-2223/aprender-markdown-alumnoudv4-crguezl-parallel'.
gh: Could not resolve to a Repository with the name 'ULL-MFP-AET-2223/aprender-markdown-casiano-rodriguez-leon-alumnoudv4'.
gh: Could not resolve to a Repository with the name 'ULL-MFP-AET-2223/aprender-markdown-luis-manuel-perez-alu0100503791'.

and gives a JSON like this one:

[
  {
    "history": [
      {
        "author": {
          "email": "[email protected]",
          "name": "afeblesc",
          "user": {
            "login": "afeblesc"
          }
        },
        "authoredDate": "2022-10-30T11:02:27Z",
        "committedDate": "2022-10-30T11:02:27Z",
        "history": {
          "totalCount": 13
        },
        "id": "C_kwDOITJiddoAKGZiNzhmNWY0Mzg1ZGZlYTZlN2Y1MTI0ZmVhMzgxZDNkNzgyNTMyYTY",
        "message": "Update README.md",
        "messageHeadline": "Update README.md",
        "oid": "fb78f5f4385dfea6e7f5124fea381d3d782532a6",
        "pushedDate": "2022-10-30T11:02:28Z"
      },
      ...
    ],
    "total": 7,
    "name": "aprender-markdown-alejandro-febles-casquero-alu0101013282"
  },
  ...
]

gh-org-commits's People

Contributors

crguezl avatar

Watchers

 avatar  avatar

gh-org-commits's Issues

Add support for secure token storage

Token storage change in latest release of gh

This is a message from the GitHub CLI team, maintainers of gh, writing to inform you that the most recent release of gh contains changes which may affect your extension. The latest release introduces the feature of storing authentication tokens in the system keyring (encrypted storage) instead of in a plain text file.
The keyrings that are supported are:

  • Keychain on macOS

  • GNOME Keyring on Linux (Secret Service dbus interface)

  • Wincred on Windows

This has huge security benefits for the users of our tool and was one of our oldest outstanding issues. Unfortunately this change has the potential to break extensions that rely on utilizing the users authentication token to work.

In order to have continued compatibility with gh there are some actions you, as an extension author, need to take. These actions will depend on the implementation of your extension.

Extensions built in Go using go-gh:

  1. Upgrade your go-gh version to v1.2.1, the latest version.

  2. Verify that in your extension retrieval of the user authentication token is done using the auth.TokenForHost function.

    • If you were previously accessing the authentication token using any other method it will no longer work.
    • Automatic resolution of the authentication token when using the API clients will continue to work without changes.

All other extensions:

  1. Verify that in your extension retrieval of the user authentication token is done by shelling out to the gh auth token command.

    • If you were previously accessing the authentication token using the gh config get command, reading the configuration file directly, or any other methods it will no longer work.

As of right now storing the authentication token in the system keyring is an opt-in feature, but in the near future it will be required and at that point if the changes above are not made then your extension will be broken for all users. If you have any questions/concerns about this change please feel free to open a discussion in the gh repo.

Thanks,
The GitHub CLI Team

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.