Skip to content

Checkout after adding a project #87

Closed

Description

@vmx

To me the workflow after adding a project that has already a history is not clear.

Here's what I did:

$ meta project add js-multihash git@github.com:multiformats/js-multihash.git
meta project adding 'git@github.com:multiformats/js-multihash.git' at js-multihash
created /home/vmx/src/pl/meta/ipld/js-multihash
Initialized empty Git repository in /home/vmx/src/pl/meta/ipld/js-multihash/.git/
set remote origin to git@github.com:multiformats/js-multihash.git
adding "js-multihash": "git@github.com:multiformats/js-multihash.git" to .meta file at /home/vmx/src/pl/meta/ipld/.meta
adding js-multihash to .gitignore at /home/vmx/src/pl/meta/ipld/.gitignore

js-multihash isn't checked out yet:

$ ls -a js-multihash
.  ..  .git

So I though I do a meta git update:

$ meta git update
all repositories in .meta are cloned locally

That doesn't do anything. Next try is a pull (that would also screw with your existing repos):

$ meta git pull 
…
here is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

A checkout would make more sense:

$ meta git checkout
js-multihash:
fatal: You are on a branch yet to be born
js-multihash: command 'git checkout ' exited with error: Error: Command failed: git checkout

There's still no proper checkout.

Next is then just removing the directory and using update:

$ rm -Rf ./js-multihash
$ meta git update

*** the following repositories have been added to .meta but are not currently cloned locally:
*** { 'js-multihash': 'git@github.com:multiformats/js-multihash.git' }
*** type 'meta git update' to correct.


 cloning missing repositories


js-multihash:
Cloning into 'js-multihash'...
remote: Enumerating objects: 7196, done.
remote: Total 7196 (delta 0), reused 0 (delta 0), pack-reused 7196
Receiving objects: 100% (7196/7196), 6.11 MiB | 5.40 MiB/s, done.
Resolving deltas: 100% (1373/1373), done.
js-multihash

That does the actual checkout as I would expect it.

So it is expected that meta project add is about new projects and not existing ones.

Activity

  1. mateodelnorte commented on Dec 18, 2018

    @mateodelnorte
    Collaborator
  2. patrickleet commented on Dec 18, 2018

    @patrickleet
    Collaborator

    meta git pull origin master should do it too

    once you set an upstream on your repo meta git pull should work

    you can add the -u flag the first time you push

    git push -u origin master
    

    Or run the command that the warning told you to run:

     git branch --set-upstream-to=origin/<branch> master
    
  3. vmx commented on Dec 18, 2018

    @vmx
    Author

    @patrickleet The git pull would also pull all other existing repos.

    I guess my main concern is consistency. I don't see an issue, that it doesn't pull the default branch automatically (although I'd prefer that). But then it's strange that meta project add does initialize an empty repository.

    I'm new to the project and just want bring up my first impressions as I personally find it valuable if someone with a fresh look contributes their pain points as they are different from being used to a system :)

  4. patrickleet commented on Dec 18, 2018

    @patrickleet
    Collaborator

    @vmx it doesn't know what the "default" branch is as one had never been set. That's what the upstream setting is for which hadn't been configured before. This warning is from git, not meta. Just want to make sure we're on the same page about that. All meta git * is doing is running git * in each folder.

    If you definitely wanted all of the upstreams for your project to be set to origin/master you could run

    meta exec "git branch --set-upstream-to=origin/master master"
    

    I'm not sure meta wants to make assumptions about settings that could be different for every project.

    I believe all meta project add does is:

    1. add project to .meta file
    2. add it to .gitignore
    3. create a folder, git init, and set the remote

    @mateodelnorte sound right?

    Even when you create a brand new project on github you need to set an upstream (notice git push -u

    image

    If your issue is addressed, may I close this issue? Or are we still disconnected on something?

  5. mateodelnorte commented on Dec 18, 2018

    @mateodelnorte
    Collaborator

    Correct @patrickleet. Meta trusts that the remote you tell it about exists. And meta project add x y only cares about setting up the bare minimum to get you working. Your meta and child repos could be in any number of states, on master, all on a feature branch, or on multiple branches. So, it doesn't make assumptions about what to check out for the new repo.

  6. vmx commented on Dec 19, 2018

    @vmx
    Author

    @patrickleet, @mateodelnorte: Thanks for being so nice/friendly to me. I'm knpo how git works and that those meta git operations just do normal git things on every repo. My goal for this issue is to make meta nice to use for the case where you want to use it for existing repositories.

    (@patrickleet) @vmx it doesn't know what the "default" branch is as one had never been set. That's what the upstream setting is for which hadn't been configured before

    My point is that meta git update does exactly what I'd expect it to do. If there are no directories yet, it checks out the default branch of those repos defiend in .meta.

    (@mateodelnorte) So, it doesn't make assumptions about what to check out for the new repo.

    It makes the assumption that I'd like to have an empty initilaized repo.

    Perhaps it makes things clearer which flow I'd propose. I just make up options, it doesn't matter if they are named like that, or if they become subcommands instead, it's just about the general idea:

    Use case: I want to add a repo with existing code:

    // This just adds the project to `.meta`
    meta project add x y
    // Checks the newly added project out as I'd expect it
    meta git update
    

    Use case: I want to add a brand new repo without any code in there yet

    // This just adds the project to `.meta`
    meta project add --init x y
    

    PS: I fear a bit that I don't find the right words and come across a noob that doesn't understand how meta works and wants to change it to a thing that it not really is. So please read all my comments in a friendly tone and as suggestions to make it better in case it aligns with the overall goal :)

  7. mateodelnorte commented on Dec 19, 2018

    @mateodelnorte
    Collaborator

    Hey @vmx. No worries. I think we get your perspective clearly. No assumptions over here that you're junior.

    I'm hesitant to do a meta git update as a component command of meta project add x y because it will potentially cause additional repos to be pulled and synced. It's a little pedantic, but a dev could know that there are large amounts of new code that they're not ready to pull down yet. Sometimes you just want to do the one, atomic, operation you're concerned with. It could be quite surprising that doing a project add ends up syncing your code. You might just not be in a position to deal with the mental overhead of worrying about what just came down.

    I would, however, entertain the idea of having something like a meta git update --include-only [name of new repo] such that only the new repo's code gets pulled. I'm fairly certain meta git update would have to be updated to allow that.

  8. vmx commented on Dec 20, 2018

    @vmx
    Author

    It could be quite surprising that doing a project add ends up syncing your code.

    That's a good point. I would then even take it a step further that it was surprising to me that an empty repo was created.

    I would, however, entertain the idea of having something like a meta git update --include-only [name of new repo] such that only the new repo's code gets pulled. I'm fairly certain meta git update would have to be updated to allow that.

    That wouldn't solve the problem that I would need to remove the repository created by meta project add x y first.

  9. mateodelnorte commented on Dec 20, 2018

    @mateodelnorte
    Collaborator

    What are you proposing?

  10. vmx commented on Dec 20, 2018

    @vmx
    Author

    I see the two use-cases mentioned in #87 (comment).

    I'm unsure if they both should be achievable with a single command, that would then e.g. be:

    // current behaviour
    meta project init x y
    // npm git update-like behaviour
    meta project import x y
    

    Or if it should be an option:

    // current behaviour
    meta project add --init x y 
    
    // npm git update-like behaviour
    meta project add x y // this doesn't create any directories
    meta git update
    
  11. aleclarson commented on Dec 21, 2018

    @aleclarson

    I think @vmx and I both have the same concerns. See here: mateodelnorte/meta-project#10

  12. throskam commented on Apr 15, 2019

    @throskam

    I completely agree with @vmx, I was really confused when I found an empty directory after adding an existing repository to the meta project.

    I did almost exactly the same mental gymnastics to make it work. I was also surprise that my use case wasn't documented and thought I was using the tool wrong (even if the logs were clear when I looked back at them).

    Maybe I'm missing something here, but why does meta initialize an empty repository and does not simply clone it ?
    As a first time user, I would expect meta project add x y to basically do git clone y x, meta project add --init x {y} to create an empty repository inside x with the remote y optionally set.

    Anyways, after that rocky start, the rest of my experience was pretty smooth :)

  13. mateodelnorte commented on Apr 15, 2019

    @mateodelnorte
    Collaborator

    I'm not against renaming the current add command to meta project init and creating a new meta project add which expects a remote to exist.

  14. drusellers commented on Apr 28, 2019

    @drusellers

    I completely agree with @vmx, I was really confused when I found an empty directory after adding an existing repository to the meta project.

    Ditto, it took me a hot minute to realize what was going on.

  15. nwillc commented on Jun 5, 2019

    @nwillc

    It confused me that the meta git pull failed after the project add, but worked if I did a fresh meta clone of same repo elsewhere...

  16. stale commented on Aug 4, 2019

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

  17. patrickleet commented on Aug 8, 2019

    @patrickleet
    Collaborator

    this was cleaned up in mateodelnorte/meta-project#25

    There is now meta project import for cloning existing repos and meta project create for initializing new ones

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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