Skip to content

Commit b009187

Browse files
Added Julia Scripts
1 parent e75d17e commit b009187

File tree

11 files changed

+268
-15
lines changed

11 files changed

+268
-15
lines changed

Manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
julia_version = "1.10.5"
44
manifest_format = "2.0"
5-
project_hash = "04a810070ef18ee41136a1d535b3d7708cc53ce9"
5+
project_hash = "7466aa371ae0c2e72224798b8708eaac8f0c47a6"
66

77
[[deps.AliasTables]]
88
deps = ["PtrArrays", "Random"]

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name = "JuliaHealthLLM"
22
authors = ["Jacob S. Zelko", "Param Thakkar"]
33

44
[deps]
5+
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
56
DotEnv = "4dc1fcf4-5e3b-5448-94ab-0c38ec0385c1"
67
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
78
DrWatson = "634d3b9d-ee7a-5ddf-bec9-22491ea816e1"

data/exp_raw/General

Lines changed: 0 additions & 1 deletion
This file was deleted.

data/exp_raw/Julia

Lines changed: 0 additions & 1 deletion
This file was deleted.

data/exp_raw/Pkg

Lines changed: 0 additions & 1 deletion
This file was deleted.

julia_repos_status.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

scripts/commitHash.jl

Whitespace-only changes.

scripts/restore_submodules.jl

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
function restore_all_submodules()
2+
try
3+
# Find the git repository root
4+
git_root = nothing
5+
try
6+
git_root = strip(read(`git rev-parse --show-toplevel`, String))
7+
catch
8+
error("Not inside a git repository")
9+
end
10+
11+
if isempty(git_root) || !isdir(git_root)
12+
error("Could not determine git repository root")
13+
end
14+
15+
# Change to git root directory for operations
16+
cd(git_root) do
17+
println("Working in git repository root: $git_root")
18+
19+
# Get list of submodules from git config
20+
println("Discovering submodules...")
21+
submodules_output = read(`git submodule status --recursive`, String)
22+
if isempty(strip(submodules_output))
23+
println("No submodules found in this repository")
24+
return
25+
end
26+
27+
# Parse submodule paths
28+
submodule_paths = String[]
29+
for line in split(submodules_output, '\n')
30+
if !isempty(strip(line))
31+
# Extract path (second field in submodule status output)
32+
parts = split(strip(line))
33+
if length(parts) >= 2
34+
push!(submodule_paths, parts[2])
35+
end
36+
end
37+
end
38+
39+
if isempty(submodule_paths)
40+
println("No active submodules found")
41+
return
42+
end
43+
44+
# Restore each submodule
45+
for path in submodule_paths
46+
println("\nProcessing submodule at: $path")
47+
if !isdir(path)
48+
println("Warning: Submodule directory $path not found, initializing...")
49+
end
50+
51+
# Initialize and update each submodule
52+
run(`git submodule init $path`)
53+
run(`git submodule update --recursive $path`)
54+
55+
# Show status for this submodule
56+
println("Current status of $path:")
57+
run(`git submodule status $path`)
58+
end
59+
60+
println("\nAll submodules successfully restored to recorded commits!")
61+
end
62+
63+
catch e
64+
println("Error occurred: ", e)
65+
println("Failed to restore submodules. Please ensure:")
66+
println("1. Git is installed and accessible")
67+
println("2. You have permission to access the submodules")
68+
println("3. You're inside a git repository (any subdirectory)")
69+
exit(1)
70+
end
71+
end
72+
73+
# Execute the function if this is the main script
74+
if abspath(PROGRAM_FILE) == @__FILE__
75+
restore_all_submodules()
76+
end

scripts/updateRepo.jl

Whitespace-only changes.

scripts/update_and_record.jl

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
using Dates
2+
3+
function update_and_record_submodules()
4+
try
5+
git_root = nothing
6+
try
7+
git_root = strip(read(`git rev-parse --show-toplevel`, String))
8+
catch
9+
error("Not inside a git repository")
10+
end
11+
12+
if isempty(git_root) || !isdir(git_root)
13+
error("Could not determine git repository root")
14+
end
15+
16+
output_file = joinpath(git_root, "submodule_hashes.txt")
17+
18+
cd(git_root) do
19+
println("Working in git repository root: $git_root")
20+
21+
println("Initializing submodules...")
22+
run(`git submodule init`)
23+
24+
println("\nUpdating submodules to latest commits...")
25+
run(`git submodule update --remote --recursive`)
26+
27+
println("\nRecording submodule states...")
28+
submodules_output = read(`git submodule status --recursive`, String)
29+
if isempty(strip(submodules_output))
30+
println("No submodules found in this repository")
31+
return
32+
end
33+
34+
open(output_file, "w") do io
35+
println(io, "Submodule Commit Hashes - Recorded on: ", Dates.now())
36+
println(io, "=========================================")
37+
38+
for line in split(submodules_output, '\n')
39+
if !isempty(strip(line))
40+
parts = split(strip(line))
41+
if length(parts) >= 2
42+
commit_hash = parts[1]
43+
commit_hash = replace(commit_hash, r"^[+-]" => "")
44+
path = parts[2]
45+
46+
println("Recording: $path @ $commit_hash")
47+
println(io, "Path: $path")
48+
println(io, "Commit: $commit_hash")
49+
println(io, "")
50+
end
51+
end
52+
end
53+
end
54+
55+
println("\nChecking for changes to commit...")
56+
status_output = read(`git status --porcelain`, String)
57+
58+
if !isempty(strip(status_output))
59+
println("Committing submodule updates...")
60+
run(`git add .gitmodules`)
61+
run(`git add $output_file`)
62+
run(`git commit -m "Updated submodules to latest commits and recorded hashes"`)
63+
println("Changes committed successfully")
64+
else
65+
println("No changes to commit - submodules were already up to date")
66+
end
67+
68+
println("\nSubmodule updates completed!")
69+
println("Hashes recorded in: $output_file")
70+
println("Current status:")
71+
run(`git submodule status --recursive`)
72+
end
73+
74+
catch e
75+
println("Error occurred: ", e)
76+
println("Failed to update submodules. Please ensure:")
77+
println("1. Git is installed and accessible")
78+
println("2. You have permission to access and modify the submodules")
79+
println("3. You're inside a git repository")
80+
println("4. You have push access to the remote repositories")
81+
exit(1)
82+
end
83+
end
84+
85+
if abspath(PROGRAM_FILE) == @__FILE__
86+
update_and_record_submodules()
87+
end

0 commit comments

Comments
 (0)