CONTRIBUTING.md
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Sun, 06 Jan 2019 01:22:46 +0300
changeset 2499 68f4f2d4516b
parent 2241 e762e234181d
permissions -rw-r--r--
use pregenerated CRC32 lookup tables for retain on Win32 and GNU/Linux

This code could be possible reused on low-end targets with limited RAM.

code to generate lookup table:
[---------------------------------------------------------------------]

/* CRC lookup table and initial state. */
uint32_t crc32_table[256];

/* Generate CRC32 lookup table. */
void GenerateCRC32Table(void)
{
unsigned int i, j;
/* Use CRC-32-IEEE 802.3 polynomial 0x04C11DB7 (bit reflected). */
uint32_t poly = 0xEDB88320;

for (i = 0; i <= 0xFF; i++)
{
uint32_t c = i;
for (j = 0 ; j < 8 ; j++)
c = (c & 1) ? (c >> 1 ) ^ poly : (c >> 1);
crc32_table[i] = c;
}
}

void main(void)
{
GenerateCRC32Table();
int j=0;
for(int i=0; i<256; i++) {
printf("0x%08X, ", crc32_table[i]);
if (++j >= 8) {
j = 0;
printf("\n");
}
}
}
[---------------------------------------------------------------------]
How Do I Submit A Good Pull Request?
----------------------------------

It's highly recommended to write nice and clean python code. Beremiz
project tries to follows most of PEP-8 recommendations. They are
automatically checked on every push and merge by Bitbucket pipelines.

To avoid pushing "unclean" code, i's recommended to add one of the following
commands to pre commit Mercurial hook into .hg/hgrc configuration file.

Unfortunately script can't distinguish between real commit and shelve. If you
are using shelve (or maybe some other affected commands), it's recommended to
use pre-<command> and post-<command> hooks to create flags to skip checks on
some operations.


```
[hooks]
pre-shelve.linter = touch .hg/skiphook
post-shelve.linter = rm .hg/skiphook
pretxncommit.linter = ./tests/tools/check_source.sh --only-changes
```
or the same done using Docker container, so result will be the same as
on Bitbucket pipeline.

```
[hooks]
pre-shelve.linter = touch .hg/skiphook
post-shelve.linter = rm .hg/skiphook
pretxncommit.linter = hg status -m -n -a -n -I '**.py' --change $HG_NODE > files.lst && docker run --volume=$PWD:/beremiz --workdir="/beremiz" --volume=$PWD/../CanFestival-3:/CanFestival-3 --memory=1g --entrypoint=/beremiz/tests/tools/check_source.sh skvorl/beremiz-requirements --files-to-check files.lst
```