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

Work on edit_*() functions #255

Merged
merged 10 commits into from Feb 17, 2018

Conversation

Projects
None yet
2 participants
@jennybc
Copy link
Member

jennybc commented Feb 16, 2018

Path handling will get even better once I tackle #177 (Use fs when released). Please view this as incremental progress in order to achieve this:

  • edit_git_ignore(scope = "user") should message if user-level .gitignoreis created de novo, as edit_r_profile() and edit_r_environ() do. Until you edit core.excludesfile in git config, the new gitignore file has no effect. But in order to do that, you need to separate path formation from path creation & editing.
  • Fixes #181 (edit_git_ignore("user") should explain how to put file into force).

Fixes #182 (Be more flexible re: name of global gitignore file).

Return path, invisibly, from all edit_*() functions.

I think overall it is more convenient to edit a path than to edit a subpath within a basepath, given the helpers scoped_path(), scoped_git_path(), and proj_path(). Hence this change:

  • edit_file(base_path, path) --> edit_file(full_path)

@jennybc jennybc force-pushed the edit-paths branch from d5acc3a to 8f9918a Feb 16, 2018

}
edit_file <- function(path) {
full_path <- path.expand(path)
create_directory(dirname(dirname(full_path)), basename(dirname(full_path)))

This comment has been minimized.

@jennybc

jennybc Feb 16, 2018

Author Member

I will make this less weird when working on #177 (Use fs when released).


if (!file.exists(full_path)) {
file.create(full_path)
}

if (!interactive() || is_testing()) {
todo("Edit ", value(path))
todo("Edit ", value(basename(path)))

This comment has been minimized.

@jennybc

jennybc Feb 16, 2018

Author Member

I will make this & the one below better when working on #177 (Use fs when released) and #198 (Path reporting).

@jennybc jennybc requested a review from hadley Feb 16, 2018

jennybc added some commits Feb 15, 2018

Change interface of edit_file()
Yesterday:

  * edit_file(base_path, path)

Today:

  * edit_file(path)

Tomorrow: something even better after the switch to fs

@jennybc jennybc force-pushed the edit-paths branch from 8f9918a to 5eaebcc Feb 16, 2018

R/edit.R Outdated
edit_git_ignore <- function(scope = c("user", "project")) {
file <- scoped_git_path(scope, ".gitignore")
if (scope == "user" && !file.exists(file)) {
todo("Tell git about this new global gitignore file for changes to take effect!")

This comment has been minimized.

@hadley

hadley Feb 16, 2018

Member

I did not know this!

This comment has been minimized.

@jennybc

jennybc Feb 16, 2018

Author Member

Maybe I should just call git2r::config() for them in this case and be done with it?

This comment has been minimized.

@hadley

hadley Feb 16, 2018

Member

Yeah, I think that's reasonable

@hadley

hadley approved these changes Feb 16, 2018

jennybc added some commits Feb 16, 2018

Shush tests
Why is this necessary on my Windows VM but not on MacOS?

@jennybc jennybc merged commit 3a96853 into master Feb 17, 2018

0 of 4 checks passed

continuous-integration/appveyor/branch Waiting for AppVeyor build to complete
Details
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details

@jennybc jennybc deleted the edit-paths branch Feb 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.