(c *C)
| 1575 | } |
| 1576 | |
| 1577 | func (s *RemoteSuite) TestCanPushShasToReference(c *C) { |
| 1578 | d := c.MkDir() |
| 1579 | d, err := os.MkdirTemp(d, "TestCanPushShasToReference") |
| 1580 | c.Assert(err, IsNil) |
| 1581 | if err != nil { |
| 1582 | return |
| 1583 | } |
| 1584 | |
| 1585 | // remote currently forces a plain path for path based remotes inside the PushContext function. |
| 1586 | // This makes it impossible, in the current state to use memfs. |
| 1587 | // For the sake of readability, use the same osFS everywhere and use plain git repositories on temporary files |
| 1588 | remote, err := PlainInit(filepath.Join(d, "remote"), true) |
| 1589 | c.Assert(err, IsNil) |
| 1590 | c.Assert(remote, NotNil) |
| 1591 | |
| 1592 | repo, err := PlainInit(filepath.Join(d, "repo"), false) |
| 1593 | c.Assert(err, IsNil) |
| 1594 | c.Assert(repo, NotNil) |
| 1595 | |
| 1596 | sha := CommitNewFile(c, repo, "README.md") |
| 1597 | |
| 1598 | gitremote, err := repo.CreateRemote(&config.RemoteConfig{ |
| 1599 | Name: "local", |
| 1600 | URLs: []string{filepath.Join(d, "remote")}, |
| 1601 | }) |
| 1602 | c.Assert(err, IsNil) |
| 1603 | if err != nil { |
| 1604 | return |
| 1605 | } |
| 1606 | |
| 1607 | err = gitremote.Push(&PushOptions{ |
| 1608 | RemoteName: "local", |
| 1609 | RefSpecs: []config.RefSpec{ |
| 1610 | // TODO: check with short hashes that this is still respected |
| 1611 | config.RefSpec(sha.String() + ":refs/heads/branch"), |
| 1612 | }, |
| 1613 | }) |
| 1614 | c.Assert(err, IsNil) |
| 1615 | if err != nil { |
| 1616 | return |
| 1617 | } |
| 1618 | |
| 1619 | ref, err := remote.Reference(plumbing.ReferenceName("refs/heads/branch"), false) |
| 1620 | c.Assert(err, IsNil) |
| 1621 | if err != nil { |
| 1622 | return |
| 1623 | } |
| 1624 | c.Assert(ref.Hash().String(), Equals, sha.String()) |
| 1625 | } |
| 1626 | |
| 1627 | func (s *RemoteSuite) TestFetchAfterShallowClone(c *C) { |
| 1628 | tempDir := c.MkDir() |
nothing calls this directly
no test coverage detected