Skip to content

Commit fd76277

Browse files
authored
Merge pull request #11 from LIM-AeroCloud/rel/0.1.1
Rel/0.1.1
2 parents 69b8205 + f228ad6 commit fd76277

File tree

12 files changed

+214
-66
lines changed

12 files changed

+214
-66
lines changed

CHANGELOG.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,34 @@
11
# Release Notes
22

33
This project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4-
The format of the release notes follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
4+
The format of the release notes follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55

6-
## [v0.1.0] - 2025-04-23
6+
## [v0.1.1] - 2025-05-24
7+
8+
### Added
9+
10+
- Overload Julia's `dirname` with a method for `SFTP` ([#9]).
11+
12+
### Deprecated
13+
14+
- The following methods have been deprecated to avoid type piracy ([#8]):
15+
- `pwd(::URI)`
16+
- `splitdir(::URI)`
17+
- `basename(::URI)`
18+
- For `joinpath`, the provided method by the `URIs` package is used, an internal `cwd` function
19+
replaces `pwd`, `splitdir` and `basename` will be removed without replacement.
20+
21+
### Removed
22+
23+
- The `joinpath(::URI, paths::AbstractString...)` method is directly removed as it seems,
24+
previously URIs' `joinpath` method was used anyway ([#8]).
25+
26+
### Fixed
27+
28+
- Ensure all `AbstractString` paths are converted to `String` in function `readdir`
29+
for correct processing of the paths ([#10]).
30+
31+
## [v0.1.0] - 2025-05-18
732

833
The initial release is based on [SFTPClient (v0.4.4)](https://github.com/stensmo/SFTPClient.jl/releases/tag/0.4.4).
934
All changes for this released are documented in respect to this version.
@@ -70,3 +95,7 @@ All changes for this released are documented in respect to this version.
7095
<!-- Links generated by Changelog.jl -->
7196

7297
[v0.1.0]: https://github.com/LIM-AeroCloud/SFTP.jl/releases/tag/v0.1.0
98+
[v0.1.1]: https://github.com/LIM-AeroCloud/SFTP.jl/releases/tag/v0.1.1
99+
[#8]: https://github.com/LIM-AeroCloud/SFTP.jl/issues/8
100+
[#9]: https://github.com/LIM-AeroCloud/SFTP.jl/issues/9
101+
[#10]: https://github.com/LIM-AeroCloud/SFTP.jl/issues/10

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SFTP"
22
uuid = "f44f501d-421f-4286-bfa3-132bd4e9b35e"
33
authors = ["Peter Bräuer <pb866.git@gmail.com>"]
4-
version = "0.1.0"
4+
version = "0.1.1"
55

66
[deps]
77
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

docs/src/filesystem.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ for more details on the `URI` struct.
1717

1818
## Navigating server paths
1919

20+
!!! warning "Deprecation warning"
21+
The [`pwd`](@ref) method for `URI` structs will be deprecated in v0.2.0 and
22+
replaced by and internal `cwd` method to avoid type piracy.
23+
2024
```@docs
2125
pwd
2226
cd(::SFTP.Client, ::AbstractString)
@@ -30,10 +34,21 @@ walkdir(::SFTP.Client, ::AbstractString; kwargs...)
3034

3135
## Analyse and manipulate server paths
3236

37+
!!! warning "Deprecation warning"
38+
All methods using `URI` instead of [`SFTP.Client`](@ref) in [`basename`](@ref)
39+
and [`splitdir`](@ref) will be deprecated in v0.2.0 to avoid type piracy.
40+
41+
!!! warning "Known issue"
42+
[URIs'](https://github.com/JuliaWeb/URIs.jl.git) `joinpath` method currently
43+
assigns two leading slashes (`//`) instead of one, if an absolute path is assigned
44+
to an empty URI path. This issue is addressed in
45+
[PR #62](https://github.com/JuliaWeb/URIs.jl/pull/62).
46+
3347
```@docs
34-
joinpath(::SFTP.Client)
35-
basename
48+
joinpath
3649
splitdir
50+
dirname
51+
basename
3752
```
3853

3954
## Getting statistics on path objects

docs/src/release-notes.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,34 @@ EditURL = "https://github.com/LIM-AeroCloud/SFTP.jl/blob/master/CHANGELOG.md"
55
# Release Notes
66

77
This project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8-
The format of the release notes follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8+
The format of the release notes follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
99

10-
## [v0.1.0](https://github.com/LIM-AeroCloud/SFTP.jl/releases/tag/v0.1.0) - 2025-04-23
10+
## [v0.1.1](https://github.com/LIM-AeroCloud/SFTP.jl/releases/tag/v0.1.1) - 2025-05-24
11+
12+
### Added
13+
14+
- Overload Julia's `dirname` with a method for `SFTP` ([#9](https://github.com/LIM-AeroCloud/SFTP.jl/issues/9)).
15+
16+
### Deprecated
17+
18+
- The following methods have been deprecated to avoid type piracy ([#8](https://github.com/LIM-AeroCloud/SFTP.jl/issues/8)):
19+
- `pwd(::URI)`
20+
- `splitdir(::URI)`
21+
- `basename(::URI)`
22+
- For `joinpath`, the provided method by the `URIs` package is used, an internal `cwd` function
23+
replaces `pwd`, `splitdir` and `basename` will be removed without replacement.
24+
25+
### Removed
26+
27+
- The `joinpath(::URI, paths::AbstractString...)` method is directly removed as it seems,
28+
previously URIs' `joinpath` method was used anyway ([#8](https://github.com/LIM-AeroCloud/SFTP.jl/issues/8)).
29+
30+
### Fixed
31+
32+
- Ensure all `AbstractString` paths are converted to `String` in function `readdir`
33+
for correct processing of the paths ([#10](https://github.com/LIM-AeroCloud/SFTP.jl/issues/10)).
34+
35+
## [v0.1.0](https://github.com/LIM-AeroCloud/SFTP.jl/releases/tag/v0.1.0) - 2025-05-18
1136

1237
The initial release is based on [SFTPClient (v0.4.4)](https://github.com/stensmo/SFTPClient.jl/releases/tag/0.4.4).
1338
All changes for this released are documented in respect to this version.

release-scripts/pre-release.jl

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
using Dates
22

3+
4+
"""
5+
get_version() -> String
6+
7+
Get the release version from the release branch name.
8+
"""
9+
function get_version()
10+
# Read current branch name
11+
out = Pipe()
12+
run(pipeline(ignorestatus(`git rev-parse --abbrev-ref HEAD`), stdout=out))
13+
close(out.in)
14+
rel = @async String(read(out))
15+
rel = String(read(out)) |> chomp
16+
return rel[5:end]
17+
end
18+
19+
320
# Parse main Project.toml
421
project = joinpath(@__DIR__, "..", "Project.toml")
522
lines = readlines(project)
6-
# Find Julia version
23+
# Set release version
724
vstring = "version = "
25+
version = get_version()
826
i = findfirst(startswith(vstring), lines)
9-
vstart, vend = findall(isequal('"'), lines[i])
10-
vstart += 1
11-
vend -= 1
12-
println("current version: ", lines[i][vstart:vend])
13-
version = VersionNumber(lines[i][vstart:vend])
14-
15-
# Set stable version
16-
if !isempty(version.prerelease)
17-
println("Drop prerelease version ", join(version.prerelease, "."))
18-
end
19-
if !isempty(version.build)
20-
println("Drop build version ", join(version.build, "."))
21-
end
22-
version = string(VersionNumber(version.major, version.minor, version.patch))
2327
lines[i] = vstring * '"' * version * '"'
2428
println("set version to ", version)
2529

src/SFTP.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ include("client.jl")
1212
include("fileexchange.jl")
1313
include("filestats.jl")
1414
include("filesystem.jl")
15+
include("deprecated.jl")
1516

1617
@static if VERSION v"1.11"
17-
eval(Meta.parse("public Client, StatStruct, download, stat, filemode, ispath, isdir, isfile, islink, pwd, cd, mv, rm, mkdir, mkpath, readdir, walkdir, joinpath, splitdir, basename"))
18+
eval(Meta.parse("public Client, StatStruct, download, stat, filemode, ispath, isdir, isfile, islink, pwd, cd, mv, rm, mkdir, mkpath, readdir, walkdir, joinpath, splitdir, dirname, basename"))
1819
end
1920

2021
export upload, statscan, URI

src/client.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,14 @@ function change_uripath(uri::URI, path::AbstractString...; trailing_slash::Union
303303
push!(paths, replace(p, Base.Filesystem.path_separator => "/"))
304304
end
305305
# Issue with // at the beginning of a path can be resolved by ensuring non-empty paths
306+
uri = URI(uri, path = cwd(uri))
306307
uri = joinpath(uri, paths...)
307308
uri = if istrue(trailing_slash)
308309
# Add trailing slash for directories and when flag is true
309310
joinpath(uri, "")
310311
elseif isfalse(trailing_slash) && endswith(uri.path, "/")
311312
# Remove trailing slash when flag is false
312-
joinpath(uri, uri.path[1:end-1])
313+
joinpath(uri, string(uri.path[1:end-1]))
313314
else # leave unchanged, when trailing_slash is nothing
314315
uri
315316
end

src/deprecated.jl

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"""
2+
pwd(uri::URI) -> String
3+
4+
Return the current path of the `uri`.
5+
"""
6+
function Base.pwd(uri::URI)::String
7+
Base.depwarn(string("pwd(::URI) is deprecated. It will be removed in v0.2.0 to avoid type piracy. ",
8+
"If you rely on this method open an issue or make a pull request to URIs.jl ",
9+
"(https://github.com/JuliaWeb/URIs.jl)"), :pwd)
10+
isempty(uri.path) ? "/" : string(uri.path)
11+
end
12+
13+
14+
"""
15+
splitdir(uri::URI) -> Tuple{URI, String}
16+
17+
Split the `uri` path into a directory and base part. The directory is returned as a `URI` with a
18+
trailing slash in the path.
19+
"""
20+
function Base.splitdir(uri::URI, path::AbstractString=".")::Tuple{URI,String}
21+
Base.depwarn(string("splitdir(::URI) is deprecated. It will be removed in v0.2.0 to avoid type piracy. ",
22+
"If you rely on this method open an issue or make a pull request to URIs.jl ",
23+
"(https://github.com/JuliaWeb/URIs.jl)"), :splitdir)
24+
# Join the path with the sftp.uri, ensure no trailing slashes in the path
25+
# ℹ First enforce trailing slashes with joinpath(..., ""), then remove the slash with path[1:end-1]
26+
path = joinpath(uri, string(path), "").path[1:end-1]
27+
# ¡ workaround for URIs joinpath
28+
startswith(path, "//") && (path = path[2:end])
29+
# Split directory from base name
30+
dir, base = splitdir(path)
31+
# Convert dir to a URI with trailing slash
32+
joinpath(URI(uri; path=dir), ""), base
33+
end
34+
35+
"""
36+
basename(uri::URI) -> String
37+
38+
Return the base name (last non-empty part after a path separator (`/` or `\\` in Windows)) of the `uri` path.
39+
"""
40+
function Base.basename(uri::URI, path::AbstractString=".")::String
41+
Base.depwarn(string("basename(::URI) is deprecated. It will be removed in v0.2.0 to avoid type piracy. ",
42+
"If you rely on this method open an issue or make a pull request to URIs.jl ",
43+
"(https://github.com/JuliaWeb/URIs.jl)"), :basename)
44+
splitdir(uri, path)[2]
45+
end

src/fileexchange.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,14 @@ function mkfolder(
254254
dirs = setdiff(dirs, conflicts)
255255
elseif istrue(force)
256256
if isempty(__test__)
257-
rm.(sftp, joinpath.(sftp, path, conflicts) .|> pwd, recursive = true, force = true)
257+
rm.(sftp, joinpath.(sftp, path, conflicts) .|> cwd, recursive = true, force = true)
258258
else
259259
rm.(joinrootpath.(__test__, path, conflicts), recursive=true, force=true)
260260
end
261261
end
262262
# Create missing folders
263263
if isempty(__test__)
264-
mkdir.(sftp, joinpath.(sftp, path, dirs) .|> pwd)
264+
mkdir.(sftp, joinpath.(sftp, path, dirs) .|> cwd)
265265
else
266266
mkdir.(joinrootpath.(__test__, path, dirs))
267267
end
@@ -327,10 +327,10 @@ function upload_file(
327327
ignore_hidden && filter!(!startswith(hide_identifier), files)
328328
if isnothing(force)
329329
!isempty(conflicts) && throw(Base.IOError("cannot overwrite existing path(s) \
330-
$(join(joinpath.(sftp, dst, files) .|> pwd, ", ", " and "))", -1))
330+
$(join(joinpath.(sftp, dst, files) .|> cwd, ", ", " and "))", -1))
331331
elseif istrue(force)
332332
if isempty(__test__)
333-
rm.(sftp, joinpath.(sftp, dst, conflicts) .|> pwd,
333+
rm.(sftp, joinpath.(sftp, dst, conflicts) .|> cwd,
334334
recursive = true, force = true)
335335
else
336336
rm.(joinrootpath.(__test__, dst, conflicts), recursive=true, force=true)

0 commit comments

Comments
 (0)