Skip to content

Commit

Permalink
Compare git tags (#11096)
Browse files Browse the repository at this point in the history
  • Loading branch information
pahor167 authored Jul 2, 2024
1 parent 4841bdc commit 8320770
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
22 changes: 22 additions & 0 deletions packages/protocol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,25 @@ How it works:
7. It calculates the size of the bytecode in kilobytes and appends the contract name, address, and size to the output file.
Output: The output is a CSV file named `onchain_bytecode_sizes_<timestamp>.csv` in the `out` directory. Each line in the file contains a contract name, its implementation address, and its size in kilobytes.
# Compare releases and get PRs changing smart contracts
To get the list of PRs that changed smart contracts between two releases, run:
```sh
yarn compare-git-tags [git_tag/branch] [git_tag/branch]
```
Example:
```sh
yarn compare-git-tags release/core-contracts/11 release/core-contracts/12
```
Example output:
PRs that made these changes:
16442165a Deactivate BlochainParameters Contract on L2 (#11008)
198f6215a SortedLinkedList Foundry Migration (#10846)
3 changes: 2 additions & 1 deletion packages/protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"anvil-devchain:stop": "./scripts/foundry/stop_anvil.sh",
"view-tags": "git for-each-ref 'refs/tags/core-contracts.*' --sort=-committerdate --format='%(color:magenta)%(committerdate:short) %(color:blue)%(tree) %(color:green)github.com/celo-org/celo-monorepo/releases/tag/%(color:yellow)%(refname:short)'",
"generate-stabletoken-files": "yarn ts-node ./scripts/generate-stabletoken-files.ts",
"truffle-verify": "yarn truffle run verify"
"truffle-verify": "yarn truffle run verify",
"compare-git-tags": "./scripts/bash/compare-git-tags.sh"
},
"dependencies": {
"@0x/sol-compiler": "^4.8.3",
Expand Down
50 changes: 50 additions & 0 deletions packages/protocol/scripts/bash/compare-git-tags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

# Function to print usage
usage() {
echo "Usage: $0 <tag/branch1> <tag/branch2>"
exit 1
}

# Check if the correct number of arguments are provided
if [ "$#" -ne 2 ]; then
usage
fi

# Assign input arguments to variables
BRANCH1=$1
BRANCH2=$2

# Fetch the latest changes from the remote repository
git fetch

# Get the list of changed Solidity files between the two branches/tags
# Exclude .t.sol files and files containing test/Test in the name
# Include only those in contracts or contracts-0.8 folders, regardless of their depth in the directory structure
CHANGED_FILES=$(git diff --name-only "$BRANCH1" "$BRANCH2" | grep -E '(.*/contracts/|.*/contracts-0.8/).*\.sol$' | grep -v '\.t\.sol$' | grep -v -i 'test')

# Print the changed Solidity files
echo "Changed Solidity files between $BRANCH1 and $BRANCH2 (excluding *.t.sol and files containing 'test'/'Test' and including only contracts or contracts-0.8 folders):"

CHANGED_FILES=$(echo "$CHANGED_FILES" | sed 's|^packages/protocol/||')
echo "$CHANGED_FILES"

# Initialize an empty string for storing commits
COMMITS=""

# Loop through each changed file and find the commits affecting those files between the two branches
for file in $CHANGED_FILES; do
FILE_COMMITS=$(git log --pretty=format:"%h %s" "$BRANCH1..$BRANCH2" -- "$file")
COMMITS+=$FILE_COMMITS
COMMITS+="\n"
done

# Extract unique commits from the collected commit messages
UNIQUE_COMMITS=$(echo -e "$COMMITS" | sort | uniq)

echo ""
echo ""
echo "********************************************"
echo ""
echo "PRs that made these changes:"
echo "$UNIQUE_COMMITS"

0 comments on commit 8320770

Please sign in to comment.