mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-21 15:43:24 +01:00
fix: Step 11 review fixes (a fork branch, a colliding tag or another remote never replaces the base)
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
87b7c922e0
commit
2a1f123d9e
4 files changed
+80
-20
No files matched your search
@@ -362,6 +362,24 @@ describe('a bare base name reads origin/<base> when it exists (#3650)', () => {
|
||||
git('update-ref', `refs/remotes/origin/${git('rev-parse', 'release/x')}`, 'HEAD');
|
||||
expect(scopeAt(dir, git('rev-parse', 'release/x')).SCOPE_BACKEND).toBe('true');
|
||||
});
|
||||
|
||||
test('a colliding tag, a fork branch over an explicit remote base, or an unrelated twin never replaces the base (#3650 review)', () => {
|
||||
const { dir, git } = behindBase('main');
|
||||
const upstreamCommit = git('rev-parse', 'origin/main');
|
||||
git('tag', 'origin/main', 'HEAD');
|
||||
expect([scopeAt(dir, 'main').SCOPE_BACKEND, scopeAt(dir, 'main').SCOPE_DOCS]).toEqual(['false', 'true']);
|
||||
git('remote', 'add', 'upstream', 'file:///nonexistent-upstream');
|
||||
git('update-ref', 'refs/remotes/upstream/main', git('rev-parse', 'main'));
|
||||
git('update-ref', 'refs/remotes/origin/upstream/main', 'HEAD');
|
||||
expect(scopeAt(dir, 'upstream/main').SCOPE_BACKEND).toBe('true');
|
||||
git('tag', '-d', 'origin/main');
|
||||
git('checkout', '-q', '--orphan', 'island');
|
||||
git('commit', '-q', '--allow-empty', '-m', 'unrelated');
|
||||
git('update-ref', 'refs/remotes/origin/main', 'HEAD');
|
||||
git('checkout', '-q', 'feature/test');
|
||||
expect(scopeAt(dir, 'main').SCOPE_BACKEND).toBe('true');
|
||||
expect(upstreamCommit).not.toBe('');
|
||||
});
|
||||
});
|
||||
|
||||
describe('uncommitted work is visible (#2299)', () => {
|
||||
|
||||
@@ -179,6 +179,33 @@ describe('gstack-gate-diff arguments and exit contract', () => {
|
||||
expect(bare.stderr).toContain('gstack-gate-diff: local main is not origin/main; base is origin/main');
|
||||
});
|
||||
|
||||
// Value: protects=a ref a contributor controls (a fork's origin/upstream/main branch, a tag named origin/main, another
|
||||
// remote's main) never replaces the base the caller named or a related local base, so it cannot hide a gate edit;
|
||||
// fails_when=resolveBase rewrites remote-qualified names, resolves the twin by its short name, or lets any remote beat a
|
||||
// related local base; why_new=the cases above have one remote and no colliding refs; seam=none; no_claim=nothing about
|
||||
// a remote's HEAD symref.
|
||||
test('a fork branch, a colliding tag or another remote never replaces the base (#3650 review)', () => {
|
||||
const src = repo({ fixture: 'rh1-skip', commit: true });
|
||||
const seed = gitIn(src, ['rev-parse', 'main']).trim();
|
||||
const clone = (remote: string) => {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-gate-diff-refs-'));
|
||||
repos.push(dir);
|
||||
gitIn(dir, ['clone', '-q', '-o', remote, '--branch', 'feature', `file://${src}`, '.']);
|
||||
return dir;
|
||||
};
|
||||
const named = clone('upstream');
|
||||
gitIn(named, ['remote', 'add', 'origin', 'file:///nonexistent-fork']);
|
||||
gitIn(named, ['update-ref', 'refs/remotes/origin/upstream/main', 'HEAD']);
|
||||
expect(summary(run(named, ['upstream/main']).stdout).tagged).toBe('RH-1:1');
|
||||
const tagged = clone('origin');
|
||||
gitIn(tagged, ['tag', 'origin/main', 'HEAD']);
|
||||
expect(summary(run(tagged, ['main']).stdout).tagged).toBe('RH-1:1');
|
||||
const fork = clone('zfork');
|
||||
gitIn(fork, ['branch', '-f', 'main', seed]);
|
||||
gitIn(fork, ['update-ref', 'refs/remotes/zfork/main', 'HEAD']);
|
||||
expect(summary(run(fork, ['main']).stdout).tagged).toBe('RH-1:1');
|
||||
});
|
||||
|
||||
test('a clone whose only remote is upstream resolves the base to upstream/main, and the fix line fetches from upstream', () => {
|
||||
const src = repo({ fixture: 'rh1-skip', commit: true });
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-gate-diff-upstream-'));
|
||||
|
||||
Reference in new issue
Block a user