Skip to content

create_from_github(): ensure forked repos are current with upstream/master #695

@ijlyttle

Description

@ijlyttle

Follow-on from #685.

If I create_from_github() on someone else's repository for which I already have a GitHub fork (e.g. r-lib/usethis), the copy that gets cloned to my computer is my master branch, not the upstream master branch. I will probably want to start my work from the upstream master, rather than my likely-stale master. I know that this is easily fixed with pr_pull_upstream(), but I wonder if this might be a useful default behavior for create_from_github().

It would seem to be a matter of adding pr_pull_upstream() to the end of:

usethis/R/create.R

Lines 198 to 202 in 2749025

if (fork) {
r <- git2r::repository(proj_get())
ui_done("Adding {ui_value('upstream')} remote: {ui_value(upstream_url)}")
git2r::remote_add(r, "upstream", upstream_url)
}

I'm assuming that the feedback (ui_done()) from pr_pull_upstream() takes care of having to add something here ourselves.

I'll start a PR for this, subject to your guidance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    gitgit, GitHub, and CI in general

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions