Skip to content

Commit

Permalink
Merge pull request #2 from xm0onh/autofill-author
Browse files Browse the repository at this point in the history
build:change
  • Loading branch information
Xm0onh authored Mar 12, 2024
2 parents 9dd5543 + 73d2f61 commit 4a520e1
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 21 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@

npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn-error.log*

*.env
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
repos:
- repo: local
hooks:
- id: update-last-update
name: Update Last Update Field
entry: scripts/update_last_update.sh
language: script
files: '\.md$'
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,39 @@ If you would like to contribute check out the following materials, and feel free
- [Code of Conduct](CODE_OF_CONDUCT.md)
- [Contributing Guide](CONTRIBUTING.md)
- [Development Guide](DEVELOPMENT.md)


### Setting Up Your Local Environment for Contribution

To ensure that your contributions include your name in the `last_update` section of documentation files automatically, follow these steps to set up your local environment:

#### Creating a `.env` File

1. At the root of your local repository clone, create a file named `.env`.
2. Inside the `.env` file, add the following line, replacing `"Your Name"` with your actual name:

```sh
AUTHOR_NAME="Your Name"
```

3. Save and close the `.env` file. This file will be used by the pre-commit hook to automatically insert your name into the `last_update` section of Markdown files.

#### Installing the Pre-commit Package

The pre-commit package is used to run scripts before each commit automatically, allowing us to update the documentation's `last_update` section seamlessly.

1. Install pre-commit on your system. If you're using pip (Python's package manager), you can install it by running:

```bash
pip install pre-commit
```

2. Make sure the update_last_update.sh script is present in the scripts/ directory at the root of your repository and is executable. You may need to run chmod +x scripts/update_last_update.sh to make it executable.

3. Run following command to set up the hook.
```bash
pre-commit install
```

With these steps completed, your local environment is set up to automatically update the last_update section of Markdown files with your name and the current date whenever you make a commit. This process helps maintain accurate documentation and attribution for contributions.

6 changes: 4 additions & 2 deletions docs/consensus/proof_of_archival_storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ keywords:
- plotting
- auditing
last_update:
date: 02/18/2024
author: Dariia Porechna
date: 03/12/2024
author: Saeid Yazdinejad
---
import Collapsible from '@site/src/components/Collapsible/Collapsible';


## Public Parameters and Values

### Protocol Constants


These parameters are fixed at the beginning of the protocol and used by all clients.

- `SLOT_PROBABILITY`: the probability of successful block in a slot (active slots coefficient), currently 1/6. This defines the expected block production rate of 1 block every 6 seconds
Expand Down
5 changes: 3 additions & 2 deletions docs/consensus/proof_of_space.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ keywords:
- tables
- plotting
last_update:
date: 02/14/2024
author: Dariia Porechna
date: 03/12/2024
author: Saeid Yazdinejad
---
import Collapsible from '@site/src/components/Collapsible/Collapsible';


This specification defines a secure proof-of-space construction for [Plotting](proof_of_archival_storage.md#plotting) and [Proving](proof_of_archival_storage.md#proving) sub-protocols of the Dilithium consensus based on Chia PoS.

## Parameters
Expand Down
5 changes: 2 additions & 3 deletions docs/consensus/proof_of_time.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ keywords:
- timekeeper
- randomness
last_update:
date: 02/14/2024
author: Dariia Porechna
date: 03/12/2024
author: Saeid Yazdinejad
---

import Collapsible from '@site/src/components/Collapsible/Collapsible';


Expand Down
7 changes: 3 additions & 4 deletions docs/crypto_primitives.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ description: Cryptographic Primitives used in the protocol.
keywords:
- cryptography
last_update:
date: 02/14/2024
author: Dariia Porechna
date: 03/12/2024
author: Saeid Yazdinejad
---

import Collapsible from '@site/src/components/Collapsible/Collapsible';

The following primitives are used in various parts of the protocol.
Expand Down Expand Up @@ -226,4 +225,4 @@ Figure 2: Querying the PoS table at a challenge index. On average 37% of indices

`is_proof_valid(k, seed, challenge, proof_of_space)``bool`

Verifies whether *proof-of-space* `proof_of_space` is valid for `challenge` of a table for `k` and `seed`.
Verifies whether *proof-of-space* `proof_of_space` is valid for `challenge` of a table for `k` and `seed`.
5 changes: 2 additions & 3 deletions docs/decex/bundles_blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ keywords:
- decex
- bundle
last_update:
date: 03/04/2024
author: Dariia Porechna
date: 03/12/2024
author: Saeid Yazdinejad
---

import Collapsible from '@site/src/components/Collapsible/Collapsible';

## Bundles
Expand Down
5 changes: 2 additions & 3 deletions docs/decex/fraud_proofs.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ keywords:
- fraud proof
- challenge period
last_update:
date: 02/22/2024
author: Dariia Porechna
date: 03/12/2024
author: Saeid Yazdinejad
---

import Collapsible from '@site/src/components/Collapsible/Collapsible';


Expand Down
5 changes: 2 additions & 3 deletions docs/decex/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ keywords:
- decex
- instantiation
last_update:
date: 03/06/2024
author: Ning Lin
date: 03/12/2024
author: Saeid Yazdinejad
---

import Collapsible from '@site/src/components/Collapsible/Collapsible';


Expand Down
38 changes: 38 additions & 0 deletions scripts/update_last_update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

# Assuming your .env file is at the root of your repository
SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
REPO_ROOT=$(dirname "$SCRIPT_DIR")
echo "REPO_ROOT: $REPO_ROOT"

source "$REPO_ROOT/.env"

date=$(date -u +"%m/%d/%Y")
author_name=$AUTHOR_NAME

# Check if AUTHOR_NAME is set
if [[ -z "$author_name" ]]; then
echo "Error: Author name is empty."
exit 1
fi

for file in $(git diff --cached --name-only | grep '\.md$'); do
awk -v date="$date" -v author="$author_name" '
BEGIN {printed=0}
/^---$/ {count++} # Count the number of occurrences of "---"
count == 1 && !printed { # Only print between the first set of "---"
if (/^last_update:/) {
print "last_update:"
print " date: " date
print " author: " author
printed=1
next
}
}
!/^last_update:/ && !/^ date:/ && !/^ author:/ {print} # Skip old last_update lines
' "$file" > temp && mv temp "$file"

# Add the updated file to the staging area
git add "$REPO_ROOT/$file"

done

0 comments on commit 4a520e1

Please sign in to comment.