Page MenuHomePhabricator

Semi-fix git cloning for non-bare repos for landing
ClosedPublic

Authored by avivey on Nov 16 2013, 12:54 AM.
Tags
None
Referenced Files
F13349533: D7592.diff
Sun, Jun 23, 5:02 AM
F13346993: D7592.diff
Sat, Jun 22, 12:35 AM
F13345684: D7592.id.diff
Fri, Jun 21, 11:12 AM
F13344867: D7592.id.diff
Fri, Jun 21, 8:49 AM
F13336118: D7592.diff
Wed, Jun 19, 4:00 AM
F13283134: D7592.diff
Sun, Jun 2, 12:52 PM
F13267929: D7592.diff
May 29 2024, 4:24 AM
F13254064: D7592.diff
May 25 2024, 3:08 AM

Details

Reviewers
epriestley
Group Reviewers
Blessed Reviewers
Commits
Restricted Diffusion Commit
rP2de96c6f0821: Semi-fix git cloning for non-bare repos for landing
Summary

If the repo isn't bare, than we need copy it's remote instead of using it.

This will probably not work if an SSH key is provided to phabricator, and in any case you must delete
all workspaces that were already created.

This will make landing those repos slower; I plan to just delete and re-clone all repos on my instance.

It will probably be simpler to just make a bare-repo a requirement of all the git-landing work.

Test Plan

landed from hosted and un-hosted repos, checked git-remote url in each newly cloned workspace.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

I think this check should be around the repository being hosted (isHosted()), not isWorkingCopyBare()? Don't we hit the same issue with bare, hosted working copies (origin pointing at file:// instead of the true remote origin)?

Just pushing this back into your queue since I think I'm not crazy, yell at me if I have no clue what I'm talking about.

src/applications/differential/DifferentialGetWorkingCopy.php
36

Oh, if the path exists it looks like $workspace is no longer initialized?

My setup is all about being hosted at github, so isHosted() is definitely not enough.

I'm trying to set up a non-bare hosted repo to see what that can do...

src/applications/differential/DifferentialGetWorkingCopy.php
36

yhe, that's a big one...

If the check is isHosted() and the logic looks like this:

`git clone file:///...`;
if (!$repository->isHosted()) {
  `git remote set-url origin ...`;
}

...that should work fine for GitHub hosting? Specifically, the clone will have a file:/// origin, and then the set-url will point it back to GitHub instead?

It will work, but will will make the next every fetch be directly from github, instead of just getting it from the local one, even if the local one is good.

Ah. What's the actual issue this is hitting, then?

That is, why do we ever need to do this? What breaks if we don't?

The original problem is that for non-bare, non-hosted repos (Which is most of what I have), the cloned workspace will be set to some old state, and the push would fail on "not-ff".

The "fix" would make it fetch from github once the initial clone is done, so it would at least be up to date; I'd prefer to have it somehow track the origin-of-origin, but I'm not sure git has that.

regarding non-bare, hosted, I found this: https://secure.phabricator.com/diffusion/P/browse/master/src/applications/differential/landing/DifferentialLandingToHostedGit.php;476b27d9c8b2b38a05ce950172d8b09a07478cf1$122-124 although I'm not sure why exactly we did that; Probably we guessed it wouldn't work?

Probably because of this error:

refusing to update checked out branch: refs/heads/master

So for the narrow context of clone-for-landing, hosted implies bare.

The reason this patch works is that while the local file:// uri is not the "right" uri, it is kept up-to-date, so when pushing to the real source, we already have the right HEAD (Barring the update delay).

avivey updated this revision to Unknown Object (????).Nov 19 2013, 12:02 AM

fix missing new API.

I'll be just as happy with just forbidding landing to non-bare, but we'll need to remember that more.

src/applications/differential/DifferentialGetWorkingCopy.php
28

See IRC; I think this should be !$repo->isHosted().

Otherwise, this seems correct.

avivey updated this revision to Unknown Object (????).Dec 30 2013, 11:20 PM

!isBare -> !isHosted

epriestley closed this revision.

Closed by commit rP2de96c6f0821 (authored by @avivey, committed by @epriestley).