From 04d55729f2d992a2542528d8e8ddf8f59d69d3db Mon Sep 17 00:00:00 2001 From: Pierre-Yves Lapersonne Date: Mon, 16 Sep 2024 12:54:53 +0200 Subject: [PATCH] [#171] [#172] Permission and path with whitespaces fixes (#173) * fix: failed to process Git repository at path with whitespaces (#172) Closes #172 Signed-off-by: Pierre-Yves Lapersonne * fix: execution permission to Shell script missing (#171) Closes #171 Signed-off-by: Pierre-Yves Lapersonne --------- Signed-off-by: Pierre-Yves Lapersonne --- CHANGELOG.md | 5 +++++ toolbox/diver/extract-emails-from-history.sh | 0 toolbox/diver/generate-contributors-file.py | 14 +++++++------- 3 files changed, 12 insertions(+), 7 deletions(-) mode change 100644 => 100755 toolbox/diver/extract-emails-from-history.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 1192eee..44cb07d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [Licenses Inventory] Update to v4.0.6 ([#160](https://github.com/Orange-OpenSource/floss-toolbox/issues/160)) +### Fixed + +- [Diver] Missing execution permission for extract-emails-from-history.sh ([#171](https://github.com/Orange-OpenSource/floss-toolbox/issues/171)) +- [Diver] Failed to process repositories at path with whitespaces ([#172](https://github.com/Orange-OpenSource/floss-toolbox/issues/172)) + ## [2.20.0](https://github.com/Orange-OpenSource/floss-toolbox/compare/2.20.0..2.19.0) - 2024-04-04 ### Added diff --git a/toolbox/diver/extract-emails-from-history.sh b/toolbox/diver/extract-emails-from-history.sh old mode 100644 new mode 100755 diff --git a/toolbox/diver/generate-contributors-file.py b/toolbox/diver/generate-contributors-file.py index 344ff4a..2f1ffb2 100755 --- a/toolbox/diver/generate-contributors-file.py +++ b/toolbox/diver/generate-contributors-file.py @@ -10,7 +10,7 @@ # Authors: See CONTRIBUTORS.txt # Software description: A toolbox of scripts to help work of forges admins and open source referents -# Version.............: 1.0.0 +# Version.............: 1.0.1 # Since...............: 03/04/2023 # Description.........: Using the Git history, generates a CONTRIBUTORS.md file @@ -56,7 +56,7 @@ print(f"✏️ Creating folder '{TEMP_FOLDER}' with internal stuff in target") os.makedirs(TEMP_FOLDER_FULL_PATH, exist_ok=True) -# Check if Git repository is empty (check if there are at least 1 commit in the logs) +# Check if Git repository is empty (check if there is at least 1 commit in the logs) command_result_output = subprocess.check_output("git log --oneline -1 > /dev/null 2>&1 | wc -l", shell=True) command_result = int(command_result_output.decode().strip()) if command_result == "0": @@ -67,15 +67,15 @@ # Dump Git logs print("✏️ Dumping Git logs") -# Create the log file, go to targetn and run the git command -# Format the output to have first name, last name (upercased) and email, sorted alphabetically ascending -# Deal also the case where we only have one value between first and last name +# Create the log file, go to target, and run the git command. +# Format the output to have first name, last name (upercased) and email, sorted ascending alphabetically. +# Deal also the case where we only have one value between first and last name. git_log_command = """ -touch {log_file} && cd {target} && git log --all --format="%aN <%aE>" | sort | uniq | awk '{{if ($2 !~ /@/) {{print $1, toupper($2), $3}} else {{print $1, $2, $3}}}}' | sort -k2 > {log_file} +touch "{log_file}" && cd "{target}" && git log --all --format="%aN <%aE>" | sort | uniq | awk '{{if ($2 !~ /@/) {{print $1, toupper($2), $3}} else {{print $1, $2, $3}}}}' | sort -k2 > "{log_file}" """.format(target=target, log_file=GIT_LOG_TEMP_FILE_PATH) os.system(git_log_command) -contributors_count_output = subprocess.check_output("cat {log_file} | wc -l".format(log_file=GIT_LOG_TEMP_FILE_PATH), shell=True) +contributors_count_output = subprocess.check_output("cat '{log_file}' | wc -l".format(log_file=GIT_LOG_TEMP_FILE_PATH), shell=True) contributors_count = int(contributors_count_output.decode().strip()) print(f"👉 Found maybe {contributors_count} contributors")