Skip to content

Reorganize the x-common files #351

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

Merged
merged 1 commit into from
Sep 9, 2016

Conversation

ErikSchierboom
Copy link
Member

This PR reorganizes the X-common files as discussed in #269.

@ErikSchierboom
Copy link
Member Author

For fun, this is the F# script I used to generate the new structure from the existing one:

open System
open System.IO

let rootDir = @"D:\programmeren\_persoonlijk\x-common"

let (</>) dir file = Path.Combine [| dir; file |]

let createDirectoryIfNotExists directory =
    if not <| Directory.Exists directory then
        Directory.CreateDirectory directory |> ignore

let copyFile source target = 
    if File.Exists source then
        File.Copy(source, target)

let createDirectory sourceMetadataFile =     
    let slug = Path.GetFileNameWithoutExtension sourceMetadataFile
    let sourceDataFile = rootDir </> (sprintf "%s.json" slug)
    let sourceDescriptionFile = rootDir </> (sprintf "%s.md" slug)
    let targetDirectory = rootDir </> "exercises" </> slug

    let targetMetadataFile = targetDirectory </> "metadata.yml"
    let targetDataFile = targetDirectory </> "data.json"
    let targetDescriptionFile = targetDirectory </> "description.md"

    createDirectoryIfNotExists targetDirectory

    copyFile sourceMetadataFile targetMetadataFile
    copyFile sourceDataFile targetDataFile
    copyFile sourceDescriptionFile targetDescriptionFile

let files = 
    Directory.EnumerateFiles(rootDir, "*.yml") 
    |> Seq.filter (fun x -> not <| x.EndsWith ".travis.yml")
    |> Seq.iter createDirectory

@Insti
Copy link
Contributor

Insti commented Aug 22, 2016

👍 for script.

Should this PR move the existing files rather than adding new copies?
(and attempt to maintain the git history.)

@Insti
Copy link
Contributor

Insti commented Aug 22, 2016

I'd also like to see the individual filenames retain their slug prefix.

exercises/accumulate/accumulate.json rather than exercises/accumulate/data.json

This way, if you copy a file elsewhere to work on it you still have some idea what the data is and we don't end up with 100's of files called data.json that are required to be in the right place to know what they contain.

@ErikSchierboom
Copy link
Member Author

I'm fairly certain the existing files should not be moved, as otherwise things will break.

As for renaming the files, that seems very redundant to me. If you want to work on the files, you will probably clone the whole repository and then the directory name already tells you the context. But maybe other people disagree?

@Insti
Copy link
Contributor

Insti commented Aug 22, 2016

kytrinyx wrote:

We can do this without breaking anything by making the API handle both cases, deploying that, and then moving all of the problems at once.

This PR would be the 'moving all the problems at once' step.
It's useful if this PR exists first, so that those testing the required api changes can use the branch to test against.

@Insti
Copy link
Contributor

Insti commented Aug 22, 2016

As for renaming the files, that seems very redundant to me

I agree it is redundant, but what value does the filename data add?

@ErikSchierboom
Copy link
Member Author

Not much, I agree. Perhaps it should be named test-data.json?

@kytrinyx
Copy link
Member

Not much, I agree. Perhaps it should be named test-data.json?

Yeah, that's better. Or canonical-data.json.

@ErikSchierboom
Copy link
Member Author

I'll rename the files to canonical-data.json.

@ErikSchierboom
Copy link
Member Author

@kytrinyx The test data JSON files have been renamed to canonical-data.json.

@kytrinyx
Copy link
Member

Would you take a look at the CONTRIBUTING.md file and see if any references there need to be updated?

@ErikSchierboom
Copy link
Member Author

I've started updating the CONTRIBUTING.md file. Would you mind taking a peek?

@kytrinyx
Copy link
Member

The CONTRIBUTING.md updates look good to me.

@ErikSchierboom
Copy link
Member Author

Is this something we want to merge, or should it be kept unmerged for a while?

@Insti
Copy link
Contributor

Insti commented Aug 27, 2016

Please keep unmerged.

  • The x-api changes are not complete.
  • This PR duplicates the exercise metadata files and obfuscates file histories.

@kytrinyx
Copy link
Member

kytrinyx commented Aug 27, 2016

I think the TODO list is something like this:

  • update this PR so that it moves files rather than copying them
  • finalize and merge the x-api changes, deploy
  • merge this PR, deploy
  • update x-api to remove the logic that handles the deprecated file locations, deploy whenever

@ErikSchierboom ErikSchierboom force-pushed the new-exercises-format branch 2 times, most recently from c99562f to 5896827 Compare August 28, 2016 17:18
@ErikSchierboom
Copy link
Member Author

@kytrinyx I've updated the PR to move the files instead of copying them.

@kytrinyx
Copy link
Member

kytrinyx commented Sep 7, 2016

@ErikSchierboom The API change has been merged and is deploying. Would you mind rebasing this onto master to make sure we have all the latest changes and newest files?

@ErikSchierboom ErikSchierboom force-pushed the new-exercises-format branch 3 times, most recently from 9eb4b97 to 974487b Compare September 7, 2016 07:01
@ErikSchierboom
Copy link
Member Author

ErikSchierboom commented Sep 7, 2016

@kytrinx I've rebased this PR onto the latest master and also ran my script again to pickup the latest changes. I'll be away for a couple of days after today by the way, so I hopefully this is enough for it to be merged.

@Insti
Copy link
Contributor

Insti commented Sep 7, 2016

It's still showing +10k lines. I would expect a move to be almost zero if the + and - balance out from a move.

@ErikSchierboom
Copy link
Member Author

I think it's because I forgot to remove the old files. I'll try to fix it tonight

@ErikSchierboom
Copy link
Member Author

@Insti I've updated the PR. This time, I think everything is okay. cc @kytrinyx

@rbasso
Copy link
Contributor

rbasso commented Sep 7, 2016

Great!
Any idea why word-count.json is the only file that seems to be copied instead of moved in Files changed?

@petertseng
Copy link
Member

My blind guess (without verification of whether the guess is correct)

\r\n vs \n ?

@ErikSchierboom
Copy link
Member Author

That would be my guess too

@ErikSchierboom
Copy link
Member Author

ErikSchierboom commented Sep 8, 2016

@rbasso @petertseng It was indeed due to line-ending issues. I've fixed it and updated the PR.

@kytrinyx
Copy link
Member

kytrinyx commented Sep 9, 2016

🎉 🎉 🎉

@Insti
Copy link
Contributor

Insti commented Sep 12, 2016

Looks great, thanks @ErikSchierboom ! ❤️

@ErikSchierboom
Copy link
Member Author

🎉

@ErikSchierboom ErikSchierboom deleted the new-exercises-format branch September 12, 2016 05:59
petertseng added a commit that referenced this pull request Sep 27, 2016
After #332 was created but before it was merged, #351 was created and
merged moving all exercises to a new structure. The nth-prime JSON file
should now be moved to its place in the new structure as well.
emcoding pushed a commit that referenced this pull request Nov 19, 2018
…r_Track

Config for Gitter Room Chat on page
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.

5 participants