devopshq / artifactory

dohq-artifactory: a Python client for Artifactory
https://devopshq.github.io/artifactory/
MIT License
270 stars 137 forks source link

`path` property of a `GenericRepository` seems to be a malformed `ArtifactoryPath` object #386

Open briantist opened 1 year ago

briantist commented 1 year ago

The path property of a repository object is an ArtifactioryPath to the repository. The str representation of this object is correct, but it seems like the parts property is missing the repository itself.

This ends up being confusing because while it looks correct as a string or repr, many other methods use the parts, for example if you used this to construct a new ArtifactoryPath.

I will try to demonstrate with some sample code:

ca = ArtifactoryPath('http://localhost:12345/artifactory')
cr = RepositoryLocal(ca, name='abc', package_type=RepositoryLocal.GENERIC)

cr.path
# ArtifactoryPath('http://localhost:12345/artifactory/abc/')

cr.parts
# ('http://localhost:123...rtifactory',)

cr.path.parts
# ('http://localhost:123...rtifactory',)

cp = ArtifactoryPath(cr.path)

cp
# ArtifactoryPath('http://localhost:12345/artifactory')

cp.parts
# ('http://localhost:123...rtifactory',)

cs = cr.path / 'subfolder'

cs
# ArtifactoryPath('http://localhost:12345/artifactory/abc/subfolder')

cs.parts
# ('http://localhost:123...rtifactory', 'subfolder')

We can workaround this by casting to str and back to a path object:

cn = ArtifactoryPath(str(cr.path))

cn
# ArtifactoryPath('http://localhost:12345/artifactory/abc/')

cn.parts
# ('http://localhost:123...ctory/abc/',)