Code Snippets
Login
Git fork cloner
Clones all forks of a repository and all branches of each fork. Also creates a root/config.php configured for localhost connection (don't forget to add the DB name and adjust the port if necessary)
Label
OWNER="GithubUserNameHere" REPO_NAME="RepositoryNameHere" API_URL="https://api.github.com/repos/$OWNER/$REPO_NAME/forks" curl -s "$API_URL?per_page=100" | tr '\n' ' ' | sed 's/},/}\n/g' | grep -oP '"owner":\s*{[^}]+}|("clone_url":\s*"[^"]+")' | paste - - | while IFS=$'\t' read -r owner_line clone_line; do username=$(echo "$owner_line" | grep -oP '"login":\s*"\K[^"]+') clone_url=$(echo "$clone_line" | grep -oP '"clone_url":\s*"\K[^"]+') folder="${REPO_NAME}-${username}" git clone "$clone_url" "$folder" cd "$folder" || continue git fetch --all for branch in $(git branch -r | grep -v '\->'); do local_branch="${branch#origin/}" if ! git show-ref --quiet "refs/heads/$local_branch"; then git branch --track "$local_branch" "$branch" fi cat > config.php <<'EOF' <?php const DB_DRIVER = "mysql"; const DB_HOST = "localhost"; const DB_LOGIN = "root"; const DB_PWD = ""; const DB_NAME = "DB_NAME_HERE"; const DB_PORT = 3307; const DB_CHARSET = "utf8mb4"; const DSN = DB_DRIVER . ":host=" . DB_HOST . ";port=" . DB_PORT . ";dbname=" . DB_NAME . ";charset=" . DB_CHARSET; EOF done cd .. done
Copy to clipboard
Copied!
©
Leerlandais 2024