-
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathpull_rawdata.sh
More file actions
executable file
·76 lines (57 loc) · 2.02 KB
/
Copy pathpull_rawdata.sh
File metadata and controls
executable file
·76 lines (57 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
# Load environment variables from .env file
if [ -f .env ]; then
source .env
else
echo "Error: .env file not found. Please create one from .env.example"
exit 1
fi
# Check if ODOO_VERSIONS is set
if [ -z "$ODOO_VERSIONS" ]; then
echo "Error: ODOO_VERSIONS not set in .env file"
exit 1
fi
# Define the repository
REPO_URL="https://github.com/odoo/documentation.git"
REMOTE_NAME="odoo-docs"
BASE_DIR="raw_data/versions"
# Initialize the main repository directory if it doesn't exist
mkdir -p $BASE_DIR
# Navigate to the base directory
cd $BASE_DIR || exit 1
# Convert comma-separated versions to array
IFS=',' read -ra VERSIONS <<< "$ODOO_VERSIONS"
# Loop through each version
for VERSION in "${VERSIONS[@]}"; do
# Trim whitespace from version
VERSION=$(echo "$VERSION" | tr -d '[:space:]')
echo "Processing version $VERSION..."
# Check if the version directory exists and contains a git repository
if [ -d "$VERSION/.git" ]; then
echo "Repository for version $VERSION already exists. Updating..."
cd $VERSION || exit 1
# Just fetch and pull the specific branch
git fetch $REMOTE_NAME $VERSION
git merge $REMOTE_NAME/$VERSION --ff-only
cd .. || exit 1
else
echo "Setting up new repository for version $VERSION..."
# Create a directory for the version
mkdir -p $VERSION
cd $VERSION || exit 1
# Initialize a git repository
git init
# Add the remote repository
git remote add $REMOTE_NAME $REPO_URL
# Enable sparse checkout
git sparse-checkout init
# Configure sparse checkout to be more specific
echo "content/**" > .git/info/sparse-checkout
# Fetch and checkout the specific branch
git fetch $REMOTE_NAME $VERSION
git checkout -b $VERSION $REMOTE_NAME/$VERSION
echo "Version $VERSION setup complete."
cd .. || exit 1
fi
done
echo "All versions have been processed successfully."