Skip to content

Commit

Permalink
Version 2.20.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pylapp committed Apr 4, 2024
2 parents 9d18b20 + 4f79ffc commit 19f0cd3
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
toolbox/github/data
toolbox/diver/data
toolbox/diver/.floss-toolbox/data
toolbox/gitlab/data
toolbox/utils/text-generator/_templates/new-GitHub-repository-contributors.fr.template.txt.result
toolbox/utils/third-party-generator/components.csv.result
Expand Down
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/Orange-OpenSource/floss-toolbox/compare/2.19.0..dev)
## [Unreleased](https://github.com/Orange-OpenSource/floss-toolbox/compare/2.20.0..dev)

## [2.20.0](https://github.com/Orange-OpenSource/floss-toolbox/compare/2.20.0..2.19.0) - 2024-04-04

### Added

- [Diver] List all contributions by contributors ([#153](https://github.com/Orange-OpenSource/floss-toolbox/issues/153))

### Fixed

- [Utils] Fix missing import in configuration.py

## [2.19.0](https://github.com/Orange-OpenSource/floss-toolbox/compare/2.19.0..2.18.0) - 2024-04-03

Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ keywords:
- audits
- history
license: Apache-2.0
version: v2.19.0
date-released: '2024-04-03'
version: v2.20.0
date-released: '2024-04-04'
10 changes: 10 additions & 0 deletions toolbox/diver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,4 +364,14 @@ Maybe a better file after fixes could be (after manual cleaning):
Barry ALLEN <[email protected]>
Lex LUTHOR <[email protected]>
Bruce WAYNE <[email protected]> <[email protected]>
```

### List contributions by contributors

Sometimes we have to check contributions and contributors so as to list who did what, e.g. if subcontractors or interns made commits on some repository.
The *list-contributions-by-contributors.sh* script will extract all authors of commits, and then create file with all contributions for each author.
Thus it will make easier to see who did what.

```shell
bash list-contributions-by-contributors.sh --project /path/to/git/repository
```
1 change: 1 addition & 0 deletions toolbox/diver/dry-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ CheckIfFileExists "./find-missing-developers-in-git-commits.sh"
CheckIfFileExists "./list-contributors-in-history.sh"
CheckIfFileExists "./lines-count.sh"
CheckIfFileExists "./generate-contributors-file.py"
CheckIfFileExists "./list-contributions-by-contributors.sh"

echo -e "\nCheck utilitary scripts..."
CheckIfFileExists "./utils/extract-contributors-lists.rb"
Expand Down
140 changes: 140 additions & 0 deletions toolbox/diver/list-contributions-by-contributors.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#!/bin/bash
# Software Name: floss-toolbox
# SPDX-FileCopyrightText: Copyright (c) Orange SA
# SPDX-License-Identifier: Apache-2.0
#
# This software is distributed under the Apache 2.0 license,
# the text of which is available at https://opensource.org/license/apache-2-0
# or see the "LICENSE.txt" file for more details.
#
# Authors: See CONTRIBUTORS.txt
# Software description: A toolbox of scripts to help work of forges admins and open source referents

# Version.............: 1.0.0
# Since...............: 04/04/2024
# Description.........: Using the Git history, provide a list of contributors' contributions
#
# Usage: bash list-contributors-in-history-emails-from-history.sh --project path/to/project
#
# Exit codes:
# 0 - normal exit
# 1 - problem with given parameters
# 2 - problem with preconditions (e.g. files to use by the script)
#

#set -euxo pipefail

VERSION="1.0.0"
SCRIPT_NAME=$(basename "$0")

# -------------
# Configuration
# -------------

NORMAL_EXIT_CODE=0
BAD_ARGUMENTS_EXIT_CODE=1
BAD_PRECONDITION_EXIT_CODE=2

# Folder fo generated files
TEMP_FOLDER=".floss-toolbox/data"

# Prefix for generated files
GENERATED_FILES_PREFIX="$$-contributions-of"

# ---------
# Functions
# --------

# \fn DisplayUsages
# \brief Displays an help message and exists
DisplayUsages(){
echo "*****************************************************"
echo "$SCRIPT_NAME - Version $VERSION"
echo "*****************************************************"
echo "USAGE:"
echo "bash $SCRIPT_NAME --project PROJECT"
echo -e "\t --project........: PROJECT must point to a git-based directory whith the commits to scan"
}

# ----------------
# Step 0 - Prepare
# ----------------

# Check the args numbers and display usage if needed
if [ "$#" -ne 2 ]; then
DisplayUsages
exit $NORMAL_EXIT_CODE
fi

# Get target folder
if [ "$1" = "--project" ]; then
if [ "$2" ]; then
git_based_project=$2
else
DisplayUsages
exit $BAD_ARGUMENTS_EXIT_CODE
fi
else
DisplayUsages
exit $BAD_ARGUMENTS_EXIT_CODE
fi

# Run!

echo "*****************************************************"
echo "$SCRIPT_NAME - Version $VERSION"
echo "*****************************************************"

echo "📋 Project to analyse is $git_based_project"
echo "📋 Prepare workspace"

# Prepare workspace

current_folder=`pwd`
workspace="$current_folder/$TEMP_FOLDER"

if [ -d "$workspace" ]; then
yes | rm -rf "$workspace"
fi
mkdir -p "$workspace"

cd "$git_based_project"

# Check if Git repository is not empty

echo "🍥 Checking git project state..."

if [ "$( git log --oneline -5 2>/dev/null | wc -l )" -eq 0 ]; then
echo "Warning: Project '$git_based_project' is a git repository without any commit, that's weird"
exit $BAD_PRECONDITION_EXIT_CODE
fi

# Get all authors

echo "🍥 Retrieving git authors..."
git_authors=$(git log --format='%ae' | sort -u)

for git_author in $git_authors; do
git log --author="$git_author" --pretty=format:"[DATE] %ad [HASH] %h [TITLE] %s" --date=short > "$workspace/$GENERATED_FILES_PREFIX-$git_author.txt"
done

# Finished!

echo "👌 Done!"

cd "$current_folder"
number_files=$(ls -l "$workspace" | grep "^-" | wc -l | tr -d '[:space:]')
echo "📈 There are $number_files generated, i.e. maybe $number_files authors with contributions"
echo "Find results in '$workspace' folder"

echo "Do you want to list all the files? (YES/no)"
read -r response
response=$(echo "$response" | tr '[:upper:]' '[:lower:]')

if [ -z $response ] || [ "$response" = "yes" ] || [ "$response" = "y" ]; then
ls -l "$workspace" | awk '{print $9}'
echo -e "\n"
fi

echo "Bye!"
exit $NORMAL_EXIT_CODE
3 changes: 2 additions & 1 deletion toolbox/utils/third-party-generator/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
# Authors: See CONTRIBUTORS.txt
# Software description: A toolbox of scripts to help work of forges admins and open source referents

# Version.............: 3.0.0
# Version.............: 3.0.1
# Since...............: 12/03/2024
# Description.........: Just to list managed licenses and share values between scripts

import sys
sys.path.append('../_')
from licenses import *

Expand Down

0 comments on commit 19f0cd3

Please sign in to comment.