Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Download feature #143

Closed
wants to merge 2 commits into from
Closed

Add Download feature #143

wants to merge 2 commits into from

Conversation

harimp
Copy link
Contributor

@harimp harimp commented Nov 26, 2014

Added a submission "download" feature for #131. It saves problems and solutions using /submissions/:key. at exercism_home/solutions/:user/:language/:slug/:key/

@@ -1,5 +1,3 @@
#!/bin/bash

set -e

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we could delete this, since the script only has a single command in it, but I would rather do that in a separate commit, since it doesn't have anything to do with the download command.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious: why did you change the file modes on the files below?

I'm open to discussing it, but if we do that it should not be mixed into the commit that adds the new feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I noticed was, when an compilation error occurs on `go build', it would shutdown the shell rather than shutting down build. Removing the exit flag solved that problem. I will put set -e back in for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, interesting. I'll experiment a bit. It sounds like we will probably want to delete it.

@kytrinyx
Copy link
Member

Thanks!

One more thing -- would you get rid of the merge commit (1b4e336), please?

It might just disappear on your own if you rebase against the upstream master. If you don't have an upstream set, you can use:

git remote add upstream https://github.com/exercism/cli.git

Then git pull --rebase upstream master

If that doesn't work, there are a number of things that you could do. I would probably try something like this:

git rebase -i HEAD^^

Then when it opens the editor with the list of commits in it, delete the merge commit, save the file, and it will reapply the second patch without the first patch.

If that gets complicated let me know and I'll help sort it out.

log.Fatal(err)
}

for k := range submission.Problem {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified a bit by getting both the key and the value:

for k, v := range submission.Problem {
  // ...
}

For clarity, perhaps we can call the local variables name and contents or something like that. Especially now that the map will be called submission.ProblemFiles, name and contents should be clear enough (filename and fileContents would probably be too much of an echo).

@harimp
Copy link
Contributor Author

harimp commented Nov 27, 2014

It looks like this fixes most of the fixes listed above. I also got rid of the merge commit. Thank you so much for taking your time to point these things out!

If there's more places to fix, I'll get right on it.

Name string `json:"name"`
Username string `json:"username"`
Problem map[string]string `json:"problem_files"`
Code map[string]string `json:"solution_files"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these be named ProblemFiles and SolutionFiles to match the new names from the API?

Since they're collections of things, the code becomes much easier to read if they're named with plurals.

@kytrinyx
Copy link
Member

Thank you! This is looking great.

The only two things that I noticed are

  1. Problem vs ProblemFiles / Code vs SolutionFiles, and
  2. the bash scripts in bin were changed to 644 rather than 755. What was the reasoning behind this?

Lastly, once it's all cleaned up, would you mind squashing the commits?

Revert version string

Fix documentation for download

Return -e flag for bash

Fix to use filepath.Join

Replace switch..case for argument check

Fix download usage msg and empty line in error handling

Replaced tab to space

Fixed upcoming change for json (problem, solution)

Renamed UserName to Username for consistency

Fixed use of change "Username"

Shorted for loop to deal with key and value

Named key and value variable

Fixed key, value error

Change to ProblemFiles and SolutionFiles

Changed bin/* files back to permission 755

Post pull request fixes
@harimp
Copy link
Contributor Author

harimp commented Nov 27, 2014

As it turns out (at least from windows point-of-view) git sets -x on file permission when checkout. It make sense since bash builds cannot be run on Windows OS. I manually added git update-index --chmod=+x bin/* to make it back to 755, and then turned core.fileMode as false to bypass any further changes.

I also squashed all commits after 6d823d8.

@kytrinyx
Copy link
Member

I squashed both commits into a single commit, since the entire change is "add download feature". I also ran go fmt, and squashed that into your commit.

The merge is here: 4c5fd74

Thank you so much for taking the time to work on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants