Skip to content

Commit 3e27640

Browse files
committed
refac
1 parent ec5f49d commit 3e27640

File tree

3 files changed

+40
-40
lines changed

3 files changed

+40
-40
lines changed

src/IO/logging.jl

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -262,36 +262,43 @@ function init_logging(filename::String, debug::Bool, silent::Bool, rank::Int64,
262262
end
263263

264264
function get_current_git_info(repo_path::AbstractString = ".")
265-
repo = LibGit2.GitRepo(repo_path)
266-
head_name = LibGit2.headname(repo)
267-
head_oid = LibGit2.head_oid(repo)
268-
dirty = LibGit2.isdirty(repo)
269-
tag_list = LibGit2.tag_list(repo)
270-
265+
dirty = false
271266
info = ""
272267
qa_vector = ["", ""]
273268

274-
if head_name == "main"
275-
info *= "Commit: $(string(head_oid)[1:7])"
276-
qa_vector[1] = "Commit: $(string(head_oid)[1:7])"
277-
else
278-
info *= "Branch: $head_name, Commit: $(string(head_oid)[1:7])"
279-
qa_vector[1] = "Commit: $(string(head_oid)[1:7])"
280-
qa_vector[2] = "Branch: $(string(head_name)[1:24])"
281-
end
269+
try
270+
repo = LibGit2.GitRepo(repo_path)
271+
head_name = LibGit2.headname(repo)
272+
head_oid = LibGit2.head_oid(repo)
273+
dirty = LibGit2.isdirty(repo)
274+
tag_list = LibGit2.tag_list(repo)
282275

283-
for tag in tag_list
284-
tag_hash = LibGit2.target(LibGit2.GitObject(repo, tag))
285-
if tag_hash == head_oid
286-
info *= ", Tag: $tag"
287-
qa_vector[1] = "Tag: $tag"
288-
break
276+
if head_name == "main"
277+
info *= "Commit: $(string(head_oid)[1:7])"
278+
qa_vector[1] = "Commit: $(string(head_oid)[1:7])"
279+
else
280+
info *= "Branch: $head_name, Commit: $(string(head_oid)[1:7])"
281+
qa_vector[1] = "Commit: $(string(head_oid)[1:7])"
282+
qa_vector[2] = "Branch: $(string(head_name)[1:24])"
289283
end
290-
end
291284

292-
if dirty
293-
info *= ", Local changes detected"
294-
qa_vector[2] = "Local changes detected"
285+
for tag in tag_list
286+
tag_hash = LibGit2.target(LibGit2.GitObject(repo, tag))
287+
if tag_hash == head_oid
288+
info *= ", Tag: $tag"
289+
qa_vector[1] = "Tag: $tag"
290+
break
291+
end
292+
end
293+
294+
if dirty
295+
info *= ", Local changes detected"
296+
qa_vector[2] = "Local changes detected"
297+
end
298+
catch e
299+
if isa(e, LibGit2.GitError)
300+
@warn "No current git info."
301+
end
295302
end
296303
return dirty, info, qa_vector
297304
end

src/Models/Material/Material_Models/BondBased/1D_Bondbased_Elastic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Calculate the elastic bond force for each node.
6666
- `time::Float64`: The current time.
6767
- `dt::Float64`: The current time step.
6868
"""
69-
function compute_model(odes::AbstractVector{Int64},
69+
function compute_model(nodes::AbstractVector{Int64},
7070
material_parameter::Dict{String,Any},
7171
block::Int64,
7272
time::Float64,

src/PeriLab.jl

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ function main(filename::String;
241241

242242
result_files = nothing
243243
outputs = nothing
244-
qa_vector::Vector{String} = []
245244

246245
try
247246
# atexit(() -> cleanup(comm))
@@ -250,26 +249,20 @@ function main(filename::String;
250249
silent = false
251250
end
252251
Logging_Module.init_logging(filename, debug, silent, rank, size)
252+
dirty,
253+
git_info,
254+
qa_vector = Logging_Module.get_current_git_info(joinpath(@__DIR__,
255+
".."))
253256
if rank == 0
254257
if !silent
255258
print_banner(size > 1)
256259
end
257260
@info "\n PeriLab version: $PERILAB_VERSION\n Copyright: Dr.-Ing. Christian Willberg, M.Sc. Jan-Timo Hesse\n Contact: christian.willberg@dlr.de, jan-timo.hesse@dlr.de\n GitHub: https://github.com/PeriHub/PeriLab.jl\n DOI: 10.1016/j.softx.2024.101700\n License: BSD-3-Clause\n ---------------------------------------------------------------\n"
258261
@info Dates.format(Dates.now(), "yyyy-mm-dd HH:MM:SS")
259-
try
260-
dirty,
261-
git_info,
262-
qa_vector = Logging_Module.get_current_git_info(joinpath(@__DIR__,
263-
".."))
264-
if dirty
265-
@warn git_info
266-
else
267-
@info git_info
268-
end
269-
catch e
270-
if isa(e, LibGit2.GitError)
271-
@warn "No current git info."
272-
end
262+
if dirty
263+
@warn git_info
264+
else
265+
@info git_info
273266
end
274267
if size > 1
275268
@info "MPI: Running on " * string(size) * " processes"

0 commit comments

Comments
 (0)