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
F14061490: D7592.diff
Mon, Nov 18, 6:46 AM
F14036535: D7592.diff
Sun, Nov 10, 10:38 AM
F13996125: D7592.id.diff
Wed, Oct 23, 6:16 PM
F13976964: D7592.diff
Oct 18 2024, 4:30 PM
F13973147: D7592.id17778.diff
Oct 17 2024, 11:22 PM
Unknown Object (File)
Oct 12 2024, 10:37 AM
Unknown Object (File)
Oct 4 2024, 7:05 PM
Unknown Object (File)
Oct 1 2024, 9:41 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

Branch
master
Lint
Lint Passed
Unit
Tests Passed

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
37

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
37

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
29

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).