github-education-resources / classroom

GitHub Classroom automates repository creation and access control, making it easy for teachers to distribute starter code and collect assignments on GitHub.
https://classroom.github.com
1.34k stars 566 forks source link

Cannot pull new code for student assignments #2520

Closed paulsmithkc closed 4 years ago

paulsmithkc commented 4 years ago

Describe the bug I can use the Classroom Assistant client to download a snapshot of my students' assignments. However, when I try to pull down a new version of their assignment I get the following error.

remote: The token in this link has expired. Please request another temporary clone link.

To Reproduce Steps to reproduce the behavior:

  1. Download and Install the Classroom Assistant application
  2. Download student repos through the client
  3. Wait a few minutes
  4. Attempt a git pull on one of the dowloaded repos.
  5. The following error appears: remote: The token in this link has expired. Please request another temporary clone link.

Expected behavior Git should be able to successfully pull down the latest version of the student's code.

Screenshots git_token_expired

womenpower19111 commented 4 years ago

Stop sending me email I have tried to unroll but you refuse stop now or else

Sent from Yahoo Mail on Android

On Tue, Jan 14, 2020 at 11:19 AM, Paul Smithnotifications@github.com wrote:
Describe the bug I can use the Classroom Assistant client to download a snapshot of my students' assignments. However, when I try to pull down a new version of their assignment I get the following error.

remote: The token in this link has expired. Please request another temporary clone link.

To Reproduce Steps to reproduce the behavior:

Expected behavior Git should be able to successfully pull down the latest version of the student's code.

Screenshots

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

womenpower19111 commented 4 years ago

Unscribe

Sent from Yahoo Mail on Android

On Wed, Jan 15, 2020 at 12:40 AM, womenpower19111notifications@github.com wrote: Stop sending me email I have tried to unroll but you refuse stop now or else

Sent from Yahoo Mail on Android

On Tue, Jan 14, 2020 at 11:19 AM, Paul Smithnotifications@github.com wrote: Describe the bug I can use the Classroom Assistant client to download a snapshot of my students' assignments. However, when I try to pull down a new version of their assignment I get the following error.

remote: The token in this link has expired. Please request another temporary clone link.

To Reproduce Steps to reproduce the behavior:

Expected behavior Git should be able to successfully pull down the latest version of the student's code.

Screenshots

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

d12 commented 4 years ago

@womenpower19111 You're receiving notifications because you're watching the repository, you can un-watch at the top of this page.

@paulsmithkc Thanks for the report! I spent some time digging this morning and I think I've tracked down the issue. In one of the affected repositories, if you run git remote -v, do you see a URL that includes an access token like this?

"https://x-access-token:faketokenfaketokenfaketoken@github.com/Your-Org-Name/Assignment-User.git"

If so, we'll just need to reset your remotes to not include the x-access-token so that Git uses your local configuration to authenticate. Let me know if this is the type of URL you see and I'll put together a quickfix script that'll fix these repos until we have a proper fix in Classroom Assistant.

paulsmithkc commented 4 years ago

Yes, the remotes do follow that pattern and include an access token.

d12 commented 4 years ago

Awesome, can you try resetting the remote and seeing if it resolves the issue?

The new URL is the one you see in git remote -v, but without the x-access-token:blahblah@.

git remote set-url origin https://github.com/your-org/your-repo-name.git
d12 commented 4 years ago

Alternatively, this one liner will fix the origin remote for you:

git remote set-url origin "https://$(git remote -v | grep "origin" | head -1 | cut -d " " -f 1 | cut -d "@" -f 2)"
paulsmithkc commented 4 years ago

Yes, that one line script does fix the remote config.

paulsmithkc commented 4 years ago

However, if applied twice it does not work. If this script is run again I get:

origin https://origin https://github.com/RankenTechnicalCollege/awd-1112-alexander-ottosson.git (fetch)

Notice the extra https://origin, because the @ sign is no longer there.

paulsmithkc commented 4 years ago

This script, which I found on another thread works better:

git remote set-url origin $(git remote -v | head -n 1 | grep -o 'github\.com.*\.git' | awk '{print "https://"$1}')

paulsmithkc commented 4 years ago

Script to do fix the origin and pull code for all my students in one go:

#!/bin/bash

pull_repo()
{
    # remove access token
    git remote set-url origin $(git remote -v | head -n 1  | grep -o 'github\.com.*\.git' | awk '{print "https://"$1}')

    # pull latest version
    git fetch origin
    git merge --ff-only origin/master
}

for student in ./*
do
    if [[ -d $student ]] && [[ -d "$student/.git" ]] && [[ $student != ./_* ]]
    then
        echo -e "\e[32m$student\e[0m"
        pushd $student > /dev/null
        pull_repo "$student"
        popd  > /dev/null
    fi
done

echo
echo -e "\e[32mdone\e[0m"
#sleep 20