Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bbenne10 committed Nov 3, 2022
0 parents commit 946db76
Show file tree
Hide file tree
Showing 12 changed files with 1,385 additions and 0 deletions.
611 changes: 611 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "pixweb"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
gloo-file = "0.2.1"
hex = "0.4.3"
js-sys = "0.3.57"
lazy_static = "1.4.0"
log = "0.4.17"
regex = "1.5.6"
stylist = { features=["yew", "yew_use_style"], version="0.10.1"}
wasm-logger = "0.2.0"
web-sys = "0.3.58"
yew = "0.19"
147 changes: 147 additions & 0 deletions checks/commit-check
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#!/usr/bin/env perl

## commit-check --- Simple git commit style checker
# Copyright (C) 2014 Tom Willemse <[email protected]>

# commit-check is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# commit-check is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with commit-ccheck. If not, see <http://www.gnu.org/licenses/>.

=head1 Commit check
This is a simple commit style checker. It is made to be used as a git
C<commit-msg> hook. It expects the name of the file to check as the
first command-line argument. The style that's checked is based on
tpope's L<A Note About Git Commit
Messages|http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html>.
=head2 Command-line options
There are 2 command line options available for use with this program:
=over
=item -0
Don't return a non-zero status when errors have been found. For use as
a git C<commit-msg> hook it is important that it does exit with a
non-zero status. But if you are using it for other tools, such as for
a flycheck checker, exiting with a non-zero status might confuse the
tools calling it.
=item -h
Show a little help text that describes the command line options and
usage.
=back
When no arguments are passed (not even the file name) the help text is
also shown and the exit status is non-0 (no matter if C<-0> has been
given).
=head2 Errors
Currently there are 5 style errors that are checked for.
=over
=item 1
The first character of the first line of the commit message should be
capitalized.
=item 2
The first line of the commit message should be no longer than 50
characters.
=item 3
The first line of the commit message should not end with a period.
=item 4
The second line of the commit message should be empty.
=item 5
No line should be longer than 72 characters.
=back
All comments are skipped and so is all whitespace at the beginning of
the file.
If any of the error conditions are encountered, and the C<-0> option
has not been given, the program will exit with a non-C<0> status. This
has the effect of stopping git from committing the message when this
program is used as a C<commit-msg> hook. Each error condition
encountered also prints a message to the standard error stream.
=cut

use strict;
use warnings;
use File::Basename;
use Getopt::Std;

my $lineno = 0;
my $status = 0;
my %arguments = ();

sub err {
my ($msg) = @_;

print STDERR basename($0) .":". $ARGV[0] .":$.: ". $msg ."\n";
$status = 1;
}

sub usage {
my ($status) = @_;
print "Usage: commit-check [-0|-h] <file>\n"
. "\n"
. "Accepted arguments:\n"
. " -0 Always return 0 exit-status, regardless of errors found.\n"
. " -h Show this help text.\n";
exit $status;
}

getopts("0h", \%arguments);

usage 0 if $arguments{h};
usage 1 if !$ARGV[0];

open(my $commitfile, "<", $ARGV[0]) or die "Couldn't open $ARGV[0]";

while (<$commitfile>) {
next if /^#/; # Discard comments
next if $lineno == 0 && /^$/; # Discard leading empty lines
$lineno++; # Start at 1, so increment first

if ($lineno == 1) {
# Special commit messages for signalling rebase --autosquash
last if /^(?:fixup|amend|squash)!/;

err "First line is not capitalized" if /^[^[:upper:]]/;
err "First line is longer than 50 characters" if /^.{51,}/;
err "First line ends with a period" if /\.$/;
next;
}

err "Second line should be empty" if $lineno == 2 && /.+/;
err "Line is longer than 72 characters" if /^.{73,}/;
}

close $commitfile;
exit $status if !$arguments{0};
exit 0;
83 changes: 83 additions & 0 deletions checks/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{ system, nixpkgs, pre-commit, rustPkg }:
let
pkgs = nixpkgs.legacyPackages.${system};
pch = pkgs.python39Packages.pre-commit-hooks;
in pre-commit.lib.${system}.run {
src = ./.;
hooks = {

# commit message formatting
check_commit_message = {
enable = true;
name = "check basic commit message style";
stages = [ "commit-msg" ];
entry = "${pkgs.perl}/bin/perl checks/commit-check";
};

# generic on-disk file checking
check_added_large_files = {
enable = true;
name = "check for added large files";
entry = "${pch}/bin/check-added-large-files";
};

fix_byte_order_marker = {
enable = true;
name = "fix byte order marker";
entry = "${pch}/bin/fix-byte-order-marker";
};

check_case_conflict = {
enable = true;
name = "check case conflict";
entry = "${pch}/bin/check-case-conflict";
};

check_merge_conflict = {
enable = true;
name = "check merge conflict";
entry = "${pch}/bin/check-merge-conflict";
};

end_of_file_fixer = {
enable = true;
name = "fix end of files";
entry = "${pch}/bin/end-of-file-fixer";
};

forbid_new_submodules = {
enable = true;
name = "forbid new submodules";
entry = "${pch}/bin/forbid-new-submodules";
};

trailing_whitespace = {
enable = true;
name = "trailing whitespace";
entry = "${pch}/bin/trailing-whitespace-fixer";
};

# nix
nixfmt.enable = true;
nix-linter.enable = true;

# rust
our_rustfmt = {
name = "rustfmt";
description = "Format Rust code.";
enable = true;
entry = "${rustPkg}/bin/cargo-fmt fmt -- --check --color always";
files = "\\.rs$";
pass_filenames = false;
};

our_clippy = {
name = "clippy";
description = "Lint Rust code.";
enable = true;
entry = "${rustPkg}/bin/cargo-clippy clippy";
files = "\\.rs$";
pass_filenames = false;
};
};
}
Loading

0 comments on commit 946db76

Please sign in to comment.