Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cmd/gh-classroom/accepted-assignments/accepted_assignments.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"strconv"
"strings"

"github.com/cli/cli/pkg/iostreams"
"github.com/cli/cli/v2/pkg/iostreams"
"github.com/cli/cli/v2/pkg/cmdutil"
"github.com/cli/go-gh"
"github.com/cli/go-gh/pkg/browser"
"github.com/cli/go-gh/pkg/tableprinter"
"github.com/cli/go-gh/pkg/term"
"github.com/cli/go-gh/v2/pkg/api"
"github.com/cli/go-gh/v2/pkg/browser"
"github.com/cli/go-gh/v2/pkg/tableprinter"
"github.com/cli/go-gh/v2/pkg/term"
"github.com/github/gh-classroom/cmd/gh-classroom/shared"
"github.com/github/gh-classroom/pkg/classroom"
"github.com/spf13/cobra"
Expand All @@ -31,7 +31,7 @@ func NewCmdAcceptedAssignments(f *cmdutil.Factory) *cobra.Command {
io := iostreams.System()
cs := io.ColorScheme()

client, err := gh.RESTClient(nil)
client, err := api.DefaultRESTClient()
var assignment classroom.Assignment
if err != nil {
log.Fatal(err)
Expand Down
8 changes: 4 additions & 4 deletions cmd/gh-classroom/assignment-grades/assignment_grades.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"os"

"github.com/cli/cli/v2/pkg/cmdutil"
"github.com/cli/go-gh"
"github.com/cli/go-gh/pkg/browser"
"github.com/cli/go-gh/pkg/term"
"github.com/cli/go-gh/v2/pkg/api"
"github.com/cli/go-gh/v2/pkg/browser"
"github.com/cli/go-gh/v2/pkg/term"
"github.com/github/gh-classroom/cmd/gh-classroom/shared"
"github.com/github/gh-classroom/pkg/classroom"
"github.com/spf13/cobra"
Expand All @@ -30,7 +30,7 @@ func NewCmdAssignmentGrades(f *cmdutil.Factory) *cobra.Command {
Run: func(cmd *cobra.Command, args []string) {
term := term.FromEnv()

client, err := gh.RESTClient(nil)
client, err := api.DefaultRESTClient()
var assignment classroom.Assignment
if err != nil {
log.Fatal(err)
Expand Down
8 changes: 4 additions & 4 deletions cmd/gh-classroom/assignment/assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (

"github.com/cli/cli/v2/pkg/cmdutil"
"github.com/cli/cli/v2/pkg/iostreams"
"github.com/cli/go-gh"
"github.com/cli/go-gh/pkg/browser"
"github.com/cli/go-gh/pkg/term"
"github.com/cli/go-gh/v2/pkg/api"
"github.com/cli/go-gh/v2/pkg/browser"
"github.com/cli/go-gh/v2/pkg/term"
"github.com/github/gh-classroom/cmd/gh-classroom/shared"
"github.com/github/gh-classroom/pkg/classroom"
"github.com/spf13/cobra"
Expand All @@ -26,7 +26,7 @@ func NewCmdAssignment(f *cmdutil.Factory) *cobra.Command {
Short: "Show the details of an assignment",
Long: "Display the details of an assignment",
Run: func(cmd *cobra.Command, args []string) {
client, err := gh.RESTClient(nil)
client, err := api.DefaultRESTClient()

if err != nil {
log.Fatal(err)
Expand Down
12 changes: 6 additions & 6 deletions cmd/gh-classroom/assignments/assignments.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (

"github.com/cli/cli/v2/pkg/cmdutil"
"github.com/cli/cli/v2/pkg/iostreams"
"github.com/cli/go-gh"
"github.com/cli/go-gh/pkg/browser"
"github.com/cli/go-gh/pkg/tableprinter"
"github.com/cli/go-gh/pkg/term"
"github.com/cli/go-gh/pkg/text"
"github.com/cli/go-gh/v2/pkg/api"
"github.com/cli/go-gh/v2/pkg/browser"
"github.com/cli/go-gh/v2/pkg/tableprinter"
"github.com/cli/go-gh/v2/pkg/term"
"github.com/cli/go-gh/v2/pkg/text"
"github.com/github/gh-classroom/cmd/gh-classroom/shared"
"github.com/github/gh-classroom/pkg/classroom"
"github.com/spf13/cobra"
Expand All @@ -33,7 +33,7 @@ func NewCmdAssignments(f *cmdutil.Factory) *cobra.Command {
io := iostreams.System()
cs := io.ColorScheme()

client, err := gh.RESTClient(nil)
client, err := api.DefaultRESTClient()
if err != nil {
log.Fatal(err)
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/gh-classroom/clone/starter-repo/starter-repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (

"github.com/MakeNowJust/heredoc"
"github.com/cli/cli/v2/pkg/cmdutil"
"github.com/cli/go-gh"
"github.com/cli/go-gh/v2"
"github.com/cli/go-gh/v2/pkg/api"
"github.com/github/gh-classroom/cmd/gh-classroom/shared"
"github.com/github/gh-classroom/pkg/classroom"
"github.com/spf13/cobra"
Expand All @@ -30,7 +31,7 @@ func NewCmdStarterRepo(f *cmdutil.Factory) *cobra.Command {
If the directory does not exists, it will be created.
`),
Run: func(cmd *cobra.Command, args []string) {
client, err := gh.RESTClient(nil)
client, err := api.DefaultRESTClient()
if err != nil {
log.Fatal(err)
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/gh-classroom/clone/student-repos/student-repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (

"github.com/MakeNowJust/heredoc"
"github.com/cli/cli/v2/pkg/cmdutil"
"github.com/cli/go-gh"
"github.com/cli/go-gh/v2"
"github.com/cli/go-gh/v2/pkg/api"
"github.com/github/gh-classroom/cmd/gh-classroom/shared"
"github.com/github/gh-classroom/pkg/classroom"
"github.com/spf13/cobra"
Expand All @@ -35,7 +36,7 @@ func NewCmdStudentRepo(f *cmdutil.Factory) *cobra.Command {
If the directory does not exists, it will be created.
`),
Run: func(cmd *cobra.Command, args []string) {
client, err := gh.RESTClient(nil)
client, err := api.DefaultRESTClient()
if err != nil {
log.Fatal(err)
}
Expand Down
12 changes: 6 additions & 6 deletions cmd/gh-classroom/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (

"github.com/cli/cli/v2/pkg/cmdutil"
"github.com/cli/cli/v2/pkg/iostreams"
"github.com/cli/go-gh"
"github.com/cli/go-gh/pkg/browser"
"github.com/cli/go-gh/pkg/tableprinter"
"github.com/cli/go-gh/pkg/term"
"github.com/cli/go-gh/pkg/text"
"github.com/cli/go-gh/v2/pkg/api"
"github.com/cli/go-gh/v2/pkg/browser"
"github.com/cli/go-gh/v2/pkg/tableprinter"
"github.com/cli/go-gh/v2/pkg/term"
"github.com/cli/go-gh/v2/pkg/text"
"github.com/github/gh-classroom/pkg/classroom"
"github.com/spf13/cobra"
)
Expand All @@ -32,7 +32,7 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
io := iostreams.System()
cs := io.ColorScheme()

client, err := gh.RESTClient(nil)
client, err := api.DefaultRESTClient()
if err != nil {
log.Fatal(err)
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/gh-classroom/pull/starter-repo/starter-repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (

"github.com/MakeNowJust/heredoc"
"github.com/cli/cli/v2/pkg/cmdutil"
"github.com/cli/go-gh"
"github.com/cli/go-gh/v2"
"github.com/cli/go-gh/v2/pkg/api"
"github.com/github/gh-classroom/cmd/gh-classroom/shared"
"github.com/github/gh-classroom/pkg/classroom"
"github.com/spf13/cobra"
Expand All @@ -25,7 +26,7 @@ func NewCmdStarterRepoPull(f *cmdutil.Factory) *cobra.Command {
Long: heredoc.Doc(`Given a starter repository that was previously cloned run a pull to get any new commits.
`),
Run: func(cmd *cobra.Command, args []string) {
client, err := gh.RESTClient(nil)
client, err := api.DefaultRESTClient()
if err != nil {
log.Fatal(err)
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/gh-classroom/pull/student-repos/student-repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (

"github.com/MakeNowJust/heredoc"
"github.com/cli/cli/v2/pkg/cmdutil"
"github.com/cli/go-gh"
"github.com/cli/go-gh/v2"
"github.com/cli/go-gh/v2/pkg/api"
"github.com/github/gh-classroom/cmd/gh-classroom/shared"
"github.com/github/gh-classroom/pkg/classroom"
"github.com/spf13/cobra"
Expand All @@ -25,7 +26,7 @@ func NewCmdStudentReposPull(f *cmdutil.Factory) *cobra.Command {
Long: heredoc.Doc(`Given a previously cloned set of student repositories run a pull on each one to get any new commits.
`),
Run: func(cmd *cobra.Command, args []string) {
client, err := gh.RESTClient(nil)
client, err := api.DefaultRESTClient()
if err != nil {
log.Fatal(err)
}
Expand Down
12 changes: 6 additions & 6 deletions cmd/gh-classroom/shared/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"sync"

"github.com/AlecAivazis/survey/v2"
"github.com/cli/go-gh/pkg/api"
"github.com/cli/go-gh/v2/pkg/api"
"github.com/github/gh-classroom/pkg/classroom"
)

func PromptForClassroom(client api.RESTClient) (classroomId classroom.Classroom, err error) {
func PromptForClassroom(client *api.RESTClient) (classroomId classroom.Classroom, err error) {
if err != nil {
return classroom.Classroom{}, err
}
Expand Down Expand Up @@ -57,7 +57,7 @@ func PromptForClassroom(client api.RESTClient) (classroomId classroom.Classroom,
return optionMap[answer.Classroom], nil
}

func PromptForAssignment(client api.RESTClient, classroomId int) (assignment classroom.Assignment, err error) {
func PromptForAssignment(client *api.RESTClient, classroomId int) (assignment classroom.Assignment, err error) {
assignmentList, err := classroom.ListAssignments(client, classroomId, 1, 100)
if err != nil {
return classroom.Assignment{}, err
Expand Down Expand Up @@ -100,7 +100,7 @@ func PromptForAssignment(client api.RESTClient, classroomId int) (assignment cla

// Get the total number of accepted assignments and the number of pages necessary to get them all
// Calculate the number of pages necessary to get all of the assignments with a given perPage
func NumberOfAcceptedAssignmentsAndPages(client api.RESTClient, assignmentID int, perPage int) (numPages, totalAccepted int) {
func NumberOfAcceptedAssignmentsAndPages(client *api.RESTClient, assignmentID int, perPage int) (numPages, totalAccepted int) {
assignment, err := classroom.GetAssignment(client, assignmentID)
if err != nil {
log.Fatal(err)
Expand All @@ -110,7 +110,7 @@ func NumberOfAcceptedAssignmentsAndPages(client api.RESTClient, assignmentID int
return
}

func ListAcceptedAssignments(client api.RESTClient, assignmentID int, page int, perPage int) (classroom.AcceptedAssignmentList, error) {
func ListAcceptedAssignments(client *api.RESTClient, assignmentID int, page int, perPage int) (classroom.AcceptedAssignmentList, error) {
response, err := classroom.GetAssignmentList(client, assignmentID, page, perPage)
if err != nil {
return classroom.AcceptedAssignmentList{}, err
Expand All @@ -129,7 +129,7 @@ type assignmentList struct {
Error error
}

func ListAllAcceptedAssignments(client api.RESTClient, assignmentID int, perPage int) (classroom.AcceptedAssignmentList, error) {
func ListAllAcceptedAssignments(client *api.RESTClient, assignmentID int, perPage int) (classroom.AcceptedAssignmentList, error) {

numPages, totalAccepted := NumberOfAcceptedAssignmentsAndPages(client, assignmentID, perPage)

Expand Down
8 changes: 4 additions & 4 deletions cmd/gh-classroom/shared/shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"sort"
"testing"

"github.com/cli/go-gh"
"github.com/cli/go-gh/v2/pkg/api"
"github.com/stretchr/testify/assert"
"gopkg.in/h2non/gock.v1"
)
Expand All @@ -30,7 +30,7 @@ func TestNumberOfAcceptedAssignmentsAndPages(t *testing.T) {
"full_name": "org1/starter-code-repo"
}
}`)
client, err := gh.RESTClient(nil)
client, err := api.DefaultRESTClient()
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -104,7 +104,7 @@ func TestListAcceptedAssignments(t *testing.T) {
}
}]`)

client, err := gh.RESTClient(nil)
client, err := api.DefaultRESTClient()
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -217,7 +217,7 @@ func TestListAllAcceptedAssignments(t *testing.T) {
Reply(200).
JSON(`[]`)

client, err := gh.RESTClient(nil)
client, err := api.DefaultRESTClient()
if err != nil {
t.Fatal(err)
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/gh-classroom/view/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (

"github.com/cli/cli/v2/pkg/cmdutil"
"github.com/cli/cli/v2/pkg/iostreams"
"github.com/cli/go-gh"
"github.com/cli/go-gh/pkg/browser"
"github.com/cli/go-gh/pkg/term"
"github.com/cli/go-gh/v2/pkg/api"
"github.com/cli/go-gh/v2/pkg/browser"
"github.com/cli/go-gh/v2/pkg/term"
"github.com/github/gh-classroom/cmd/gh-classroom/shared"
"github.com/github/gh-classroom/pkg/classroom"
"github.com/spf13/cobra"
Expand All @@ -25,7 +25,7 @@ func NewCmdView(f *cmdutil.Factory) *cobra.Command {
Long: `Display the classroom ID, classroom slug, title and other information about a classroom.
With "--web", open the classroom in a browser instead.`,
Run: func(cmd *cobra.Command, args []string) {
client, err := gh.RESTClient(nil)
client, err := api.DefaultRESTClient()

if err != nil {
log.Fatal(err)
Expand Down
Loading
Loading