Skip to content

Commit

Permalink
Merge pull request #25 from felipealfonsog/development
Browse files Browse the repository at this point in the history
Updates in the code for AUR and others
  • Loading branch information
felipealfonsog authored Mar 7, 2024
2 parents 5577255 + e9e75ae commit e16e444
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 9 deletions.
24 changes: 16 additions & 8 deletions src/aur-dev/git_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,24 @@ def update_github_repositories(main_directory, include_aur):
def main():
welcome()
current_directory = os.getcwd()
main_directory = input(f"Current directory is: {current_directory}\nDo you want to update repositories here? (Y/N, default is Y): ")
if main_directory.lower() != 'n':
exclude_choice = input("Do you want to exclude directories with the '-aur' suffix? (Press Enter for Yes, N for No, default is Yes): ").lower()
if exclude_choice == '' or exclude_choice == 'y':
include_aur = False
if not any('.git' in root for root, _, _ in os.walk(current_directory)):
print("No GitHub repositories found in the current directory or its subdirectories. Exiting.")
return
main_directory = input(f"Current directory is: {current_directory}\nDo you want to update repositories here? (Press Enter for No, Y for Yes default is No): ")
if main_directory.lower() != 'y':
abort_choice = input("Do you want to abort the process? (Press Enter for No, Y for Yes default is No): ").lower()
if abort_choice == 'y':
print("Operation aborted.")
return
else:
include_aur = True
update_github_repositories(current_directory, include_aur)
print("You need to be inside a directory with GitHub repositories to update them.")
return
exclude_choice = input("Do you want to exclude directories with the '-aur' suffix? (Press Enter for Yes, N for No, default is Yes): ").lower()
if exclude_choice == '' or exclude_choice == 'y':
include_aur = False
else:
print("You need to be inside a directory with GitHub repositories to update them.")
include_aur = True
update_github_repositories(current_directory, include_aur)

if __name__ == "__main__":
main()
7 changes: 7 additions & 0 deletions src/aur-dev/git_updater.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ main() {
include_aur=true
fi
update_github_repositories "$current_directory" "$include_aur"
elif [[ "$main_directory" =~ [Nn] ]]; then
read -p "Do you want to abort the process? (Press Enter for No, Y for Yes default is No): " abort_choice
if [[ "$abort_choice" == '' || "$abort_choice" =~ [Yy] ]]; then
echo "Operation aborted."
else
echo "You need to be inside a directory with GitHub repositories to update them."
fi
else
echo "You need to be inside a directory with GitHub repositories to update them."
fi
Expand Down
37 changes: 37 additions & 0 deletions src/aur-dev/v.0.0.8/git_updater.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import os

def welcome():
print("Welcome to GitHub Repository Updater -GitSyncMaster-!")
print("This software was developed by Computer Science Engineer Felipe Alfonso González - Github: github.com/felipealfonsog - Under the BSD 3-clause license.")
print("Developed from Chile with love.")
print("----------------------------------------------------")
print("This software will update all GitHub repositories within the current directory or its subdirectories.")

def update_github_repositories(main_directory, include_aur):
print("\nUpdating GitHub repositories...\n")
for root, dirs, files in os.walk(main_directory):
if '.git' in dirs:
git_dir = os.path.join(root, '.git')
if os.path.isdir(git_dir):
if include_aur or not root.endswith("-aur"):
print(f"Updating repository in {root}")
os.chdir(root)
os.system('git pull')
os.chdir(main_directory)

def main():
welcome()
current_directory = os.getcwd()
main_directory = input(f"Current directory is: {current_directory}\nDo you want to update repositories here? (Y/N, default is Y): ")
if main_directory.lower() != 'n':
exclude_choice = input("Do you want to exclude directories with the '-aur' suffix? (Press Enter for Yes, N for No, default is Yes): ").lower()
if exclude_choice == '' or exclude_choice == 'y':
include_aur = False
else:
include_aur = True
update_github_repositories(current_directory, include_aur)
else:
print("You need to be inside a directory with GitHub repositories to update them.")

if __name__ == "__main__":
main()
42 changes: 42 additions & 0 deletions src/aur-dev/v.0.0.8/git_updater.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

welcome() {
echo "Welcome to GitHub Repository Updater -GitSyncMaster-!"
echo "This software was developed by Computer Science Engineer Felipe Alfonso González - Github: github.com/felipealfonsog - Under the BSD 3-clause license."
echo "Developed from Chile with love."
echo "----------------------------------------------------"
echo "This software will update all GitHub repositories within the current directory or its subdirectories."
}

update_github_repositories() {
echo -e "\nUpdating GitHub repositories...\n"
for dir in "$1"/*/; do
if [ -d "$dir/.git" ]; then
if [ "$2" = true ] || [[ ! "$dir" =~ -aur$ ]]; then
echo "Updating repository in $dir"
cd "$dir" || exit
git pull
cd - || exit
fi
fi
done
}

main() {
welcome
current_directory=$(pwd)
read -p "Current directory is: $current_directory. Do you want to update repositories here? (Press Enter for Yes, N for No, default is Yes): " main_directory
if [[ "$main_directory" == '' || "$main_directory" =~ [Yy] ]]; then
read -p "Do you want to exclude directories with the '-aur' suffix? (Press Enter for Yes, N for No, default is Yes): " exclude_choice
if [[ "$exclude_choice" == '' || "$exclude_choice" =~ [Yy] ]]; then
include_aur=false
else
include_aur=true
fi
update_github_repositories "$current_directory" "$include_aur"
else
echo "You need to be inside a directory with GitHub repositories to update them."
fi
}

main
2 changes: 1 addition & 1 deletion src/aur-pkg/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Mantenedor: Felipe Alfonso Gonzalez <[email protected]>
pkgname=gitsync
pkgver=0.0.8
pkgver=0.0.9
pkgrel=1
pkgdesc="GitSyncMaster: Automate updating multiple Git repositories within a directory structure effortlessly."
arch=('x86_64')
Expand Down

0 comments on commit e16e444

Please sign in to comment.