Skip to content

Support fresh repositories (with no commits) #19

Open
@timwis

Description

@timwis

At the moment GitSheets has to be run against an initialised git directory with at least one commit made, so we have a bunch of git commit -m 'init' --allow-empty in tests/docs/etc. I believe the reason it requires at least one commit is that hologit/Repo's getFromEnvironment static method is running git rev-parse --verify HEAD (see here).

According to @themightychris:

There's a wrapper for that in Git or Hologit that provides for just returning null instead of throwing an exception for cases where potential nonexistense is anticipated
We should use that call instead, and I'm leaning towards it being best to generate an initialization commit rather than just start a new chain from an import with no parent
Link. use the Repo class to "open" the repo ^ that will let you instantiate it with a selected ref. instead of hardcoding HEAD everywhere.

To which I replied:

in other words Repo.createFromEnvironment({ ref: await resolveRef() }) ?
won't it resolve to null and we're in the same situation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions