Skip to content

Commit

Permalink
fix dev server handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitpaulk committed Oct 30, 2023
1 parent 3e77ddb commit e1250bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 3 additions & 5 deletions internal/utils/codecrafters_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package utils

import (
"encoding/json"
"errors"
"fmt"
"os"
"time"
Expand Down Expand Up @@ -72,20 +71,19 @@ func (c CodecraftersClient) CreateSubmission(repositoryId string, commitSha stri
})

if err != nil {
fmt.Fprintf(os.Stderr, "failed to submit code to CodeCrafters: %s", err)
fmt.Fprintf(os.Stderr, "failed to submit code to CodeCrafters: %s\n", err)
return CreateSubmissionResponse{}, err
}

if !response.Ok && response.StatusCode != 403 {
fmt.Fprintf(os.Stderr, "failed to submit code to CodeCrafters. status code: %d. body: %s", response.StatusCode, response.String())
return CreateSubmissionResponse{}, errors.New("dummy")
return CreateSubmissionResponse{}, fmt.Errorf("failed to submit code to CodeCrafters. status code: %d, body: %s", response.StatusCode, response.String())
}

createSubmissionResponse := CreateSubmissionResponse{}

err = json.Unmarshal(response.Bytes(), &createSubmissionResponse)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to submit code to CodeCrafters: %s", err)
fmt.Fprintf(os.Stderr, "failed to submit code to CodeCrafters: %s\n", err)
return CreateSubmissionResponse{}, err
}

Expand Down
8 changes: 8 additions & 0 deletions internal/utils/git_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ func (r GitRemote) CodecraftersServerURL() string {
return replacedUrl
}

newDevServerRegex := regexp.MustCompile("(.*)-git.ccdev.dev")

if newDevServerRegex.MatchString(r.Url) {
replacedUrl := regexp.MustCompile("-git").ReplaceAllString(r.Url, "-backend")
replacedUrl = regexp.MustCompile("ccdev.dev/.*").ReplaceAllString(replacedUrl, "ccdev.dev")
return replacedUrl
}

return ""
}

Expand Down

0 comments on commit e1250bb

Please sign in to comment.