Untitled
unknown
plain_text
2 years ago
1.7 kB
5
Indexable
Untitled
import os
import subprocess
# List of package directories within the repository
package_directories = ["package1", "package2", "package3"]
# Function to print the HEAD for a given package directory
def print_package_head(package_dir):
try:
# Change directory to the package directory
os.chdir(package_dir)
# Run the Git command to print the HEAD
result = subprocess.run(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, text=True)
if result.returncode == 0:
# Print the HEAD of the current package
print(f"Package: {package_dir}, HEAD: {result.stdout.strip()}")
else:
print(f"Error in {package_dir}: Git command failed")
except Exception as e:
print(f"Error in {package_dir}: {str(e)}")
finally:
# Change back to the original working directory
os.chdir("..")
# Loop through each package directory and print the HEAD
for package_dir in package_directories:
print_package_head(package_dir)
#!/bin/bash
# Replace 'path/to/your/repo' with the actual path to your Git repository
repo_path="path/to/your/repo"
# Change to the repository directory
cd "$repo_path" || exit 1
# List all subdirectories (assuming each subdirectory corresponds to a package)
for package_dir in */; do
# Enter the package directory
cd "$package_dir" || continue
# Get the current branch and commit at HEAD
branch=$(git symbolic-ref —short HEAD)
commit=$(git rev-parse HEAD)
# Print package name, branch, and commit
echo "Package: $package_dir"
echo "Branch: $branch"
echo "HEAD Commit: $commit"
echo
# Return to the parent directory
cd ..
done
Editor is loading...