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
Merged

Work on edit_*() functions #255

merged 10 commits into from
Feb 17, 2018

Conversation

jennybc
Copy link
Member

@jennybc 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 edit_git_ignore("user") should explain how to put file into force #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)

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

Choose a reason for hiding this comment

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

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)))
Copy link
Member Author

Choose a reason for hiding this comment

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

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 February 16, 2018 06:20
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!")
Copy link
Member

Choose a reason for hiding this comment

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

I did not know this!

Copy link
Member Author

@jennybc jennybc Feb 16, 2018

Choose a reason for hiding this comment

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

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

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think that's reasonable

@jennybc jennybc merged commit 3a96853 into master Feb 17, 2018
@jennybc jennybc deleted the edit-paths branch February 17, 2018 06:32
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.

None yet

2 participants