mirror of
				https://github.com/XRPLF/clio.git
				synced 2025-11-04 11:55:51 +00:00 
			
		
		
		
	fix: Use git lfs install and fix verify-commits hook (#2129)
				
					
				
			This commit is contained in:
		@@ -7,7 +7,7 @@
 | 
				
			|||||||
# Common tasks
 | 
					# Common tasks
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# - Run on all files:   pre-commit run --all-files
 | 
					# - Run on all files:   pre-commit run --all-files
 | 
				
			||||||
# - Register git hooks: pre-commit install --install-hooks
 | 
					# - Register git hooks: pre-commit install --hook-type pre-commit --hook-type pre-push
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# See https://pre-commit.com for more information
 | 
					# See https://pre-commit.com for more information
 | 
				
			||||||
# See https://pre-commit.com/hooks.html for more hooks
 | 
					# See https://pre-commit.com/hooks.html for more hooks
 | 
				
			||||||
@@ -94,33 +94,7 @@ repos:
 | 
				
			|||||||
      - id: verify-commits
 | 
					      - id: verify-commits
 | 
				
			||||||
        name: Verify Commits
 | 
					        name: Verify Commits
 | 
				
			||||||
        entry: pre-commit-hooks/verify-commits.sh
 | 
					        entry: pre-commit-hooks/verify-commits.sh
 | 
				
			||||||
        types: [text]
 | 
					        always_run: true
 | 
				
			||||||
        language: script
 | 
					 | 
				
			||||||
        pass_filenames: false
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  - repo: local
 | 
					 | 
				
			||||||
    hooks:
 | 
					 | 
				
			||||||
      - id: lfs-post-checkout
 | 
					 | 
				
			||||||
        name: LFS Post Checkout
 | 
					 | 
				
			||||||
        entry: pre-commit-hooks/lfs/post-checkout
 | 
					 | 
				
			||||||
        types: [text]
 | 
					 | 
				
			||||||
        stages: [post-checkout]
 | 
					 | 
				
			||||||
        language: script
 | 
					 | 
				
			||||||
      - id: lfs-post-commit
 | 
					 | 
				
			||||||
        name: LFS Post Commit
 | 
					 | 
				
			||||||
        entry: pre-commit-hooks/lfs/post-commit
 | 
					 | 
				
			||||||
        types: [text]
 | 
					 | 
				
			||||||
        stages: [post-commit]
 | 
					 | 
				
			||||||
        language: script
 | 
					 | 
				
			||||||
      - id: lfs-post-merge
 | 
					 | 
				
			||||||
        name: LFS Post Merge
 | 
					 | 
				
			||||||
        entry: pre-commit-hooks/lfs/post-merge
 | 
					 | 
				
			||||||
        types: [text]
 | 
					 | 
				
			||||||
        stages: [post-merge]
 | 
					 | 
				
			||||||
        language: script
 | 
					 | 
				
			||||||
      - id: lfs-pre-push
 | 
					 | 
				
			||||||
        name: LFS Pre Push
 | 
					 | 
				
			||||||
        entry: pre-commit-hooks/lfs/pre-push
 | 
					 | 
				
			||||||
        types: [text]
 | 
					 | 
				
			||||||
        stages: [pre-push]
 | 
					        stages: [pre-push]
 | 
				
			||||||
        language: script
 | 
					        language: script
 | 
				
			||||||
 | 
					        pass_filenames: false
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,6 +17,16 @@ To contribute, please:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
> **Note:** Please read the [Style guide](#style-guide).
 | 
					> **Note:** Please read the [Style guide](#style-guide).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### `git lfs` hooks
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Install `git lfs` hooks using the following command:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```bash
 | 
				
			||||||
 | 
					git lfs install
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					> **Note:** You need to install Git LFS hooks before installing `pre-commit` hooks.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### `pre-commit` hooks
 | 
					### `pre-commit` hooks
 | 
				
			||||||
 | 
					
 | 
				
			||||||
To ensure code quality and style, we use [`pre-commit`](https://pre-commit.com/).
 | 
					To ensure code quality and style, we use [`pre-commit`](https://pre-commit.com/).
 | 
				
			||||||
@@ -25,7 +35,7 @@ Run the following command to enable `pre-commit` hooks that help with Clio devel
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
pip3 install pre-commit
 | 
					pip3 install pre-commit
 | 
				
			||||||
pre-commit install
 | 
					pre-commit install --hook-type pre-commit --hook-type pre-push
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
`pre-commit` takes care of running each tool in [`.pre-commit-config.yaml`](https://github.com/XRPLF/clio/blob/develop/.pre-commit-config.yaml) in a separate environment.
 | 
					`pre-commit` takes care of running each tool in [`.pre-commit-config.yaml`](https://github.com/XRPLF/clio/blob/develop/.pre-commit-config.yaml) in a separate environment.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,3 +0,0 @@
 | 
				
			|||||||
#!/bin/sh
 | 
					 | 
				
			||||||
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-checkout' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; }
 | 
					 | 
				
			||||||
git lfs post-checkout "$@"
 | 
					 | 
				
			||||||
@@ -1,3 +0,0 @@
 | 
				
			|||||||
#!/bin/sh
 | 
					 | 
				
			||||||
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-commit' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; }
 | 
					 | 
				
			||||||
git lfs post-commit "$@"
 | 
					 | 
				
			||||||
@@ -1,3 +0,0 @@
 | 
				
			|||||||
#!/bin/sh
 | 
					 | 
				
			||||||
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-merge' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; }
 | 
					 | 
				
			||||||
git lfs post-merge "$@"
 | 
					 | 
				
			||||||
@@ -1,3 +0,0 @@
 | 
				
			|||||||
#!/bin/sh
 | 
					 | 
				
			||||||
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'pre-push' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; }
 | 
					 | 
				
			||||||
git lfs pre-push "$@"
 | 
					 | 
				
			||||||
@@ -39,16 +39,14 @@ verify_tag_signed() {
 | 
				
			|||||||
    fi
 | 
					    fi
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
while read local_ref local_oid remote_ref remote_oid; do
 | 
					# Check some things if we're pushing a branch called "release/"
 | 
				
			||||||
    # Check some things if we're pushing a branch called "release/"
 | 
					if echo "$PRE_COMMIT_REMOTE_BRANCH" | grep ^refs\/heads\/release\/ &> /dev/null ; then
 | 
				
			||||||
    if echo "$remote_ref" | grep ^refs\/heads\/release\/ &> /dev/null ; then
 | 
					    version=$(git tag --points-at HEAD)
 | 
				
			||||||
        version=$(git tag --points-at HEAD)
 | 
					    echo "Looks like you're trying to push a $version release..."
 | 
				
			||||||
        echo "Looks like you're trying to push a $version release..."
 | 
					    echo "Making sure you've signed and tagged it."
 | 
				
			||||||
        echo "Making sure you've signed and tagged it."
 | 
					    if verify_commit_signed && verify_tag && verify_tag_signed ; then
 | 
				
			||||||
        if verify_commit_signed && verify_tag && verify_tag_signed ; then
 | 
					        : # Ok, I guess you can push
 | 
				
			||||||
            : # Ok, I guess you can push
 | 
					    else
 | 
				
			||||||
        else
 | 
					        exit 1
 | 
				
			||||||
            exit 1
 | 
					 | 
				
			||||||
        fi
 | 
					 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
done
 | 
					fi
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user