Grader-Service icon indicating copy to clipboard operation
Grader-Service copied to clipboard

Ensure that HEAD points to an active reference (so we can list the tree)

Open adammccartney opened this issue 2 years ago • 1 comments

Describe the bug

The command git ls-tree HEAD should list the contents of a tree object. In other words, it should show the state of the tree at the ref and, by extension, the commit pointed to by HEAD.

The current value for HEAD is invalid and returns a fatal error when we try to use the command:

grader-service@grader-service-<somewhere>:~/git/jaas20/1/user/amccartn$ git ls-tree HEAD
fatal: Not a valid object name HEAD
grader-service@grader-service-<somewhere>:~/git/jaas20/1/user/fjaeger$ git ls-tree HEAD
fatal: Not a valid object name HEAD

To Reproduce

Steps to reproduce the behavior:

  1. log in to https://jaas20.jupyter.hpc.tuwien.ac.at as a registered user
  2. Submit a solution to the first assignment
  3. Attach a shell to the pod running grader-service
  4. cd git/jaas20/1/user/<your-user> && git rev-parse HEAD

Expected behavior

grader-service@grader-service-<somewhere>:~/git/jaas20/1/user/amccartn$ git ls-tree HEAD
040000 tree 849f99b94187f3f4784e68b3176313a506c1bd25    .ipynb_checkpoints
100644 blob b9331bdd9368c6d889b75593ff4544db4f9052a4    adsolve.ipynb
100644 blob e059a52c231df1ef34e98b0f64512d4755e82123    data.csv

Aspects of a Solution

HEAD tries to reference the master branch

grader-service@grader-service-<somewhere>:~/git/jaas20/1/user/amccartn$ cat HEAD
ref: refs/heads/master

We can see by examining the refs, or git branches that master does not exist:

grader-service@grader-service-<somewhere>:~/git/jaas20/1/user/amccartn$ ls -l refs/heads/
total 1
-rw-r--r-- 1 grader-service grader-service 41 May  4 11:43 main
grader-service@grader-service-555c5c9b7d-f2qdj:~/git/jaas20/1/user/amccartn$ git branch
* main

We need to ensure that HEAD points to a valid commit, i.e. refs/heads/main

The subroutine that establishes the default global config for grader service should also run the command:

git config --global init.defaultbranch main

adammccartney avatar May 04 '23 12:05 adammccartney

Actually this is the default behavior assuming that we have just initialized a new repository. However, as soon as we commit something, the HEAD should be updated to point at the most recent commit.

I would assume that hitting "submit" from the jupyter client causes the files I have worked on to be committed to the repository. Definitely the blob, tree and commit appear in the git directory after a "submit" takes place. Is there a reason that we are somehow avoiding the update to HEAD as we do this commit?

adammccartney avatar May 05 '23 07:05 adammccartney