Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/bin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Check bin/auto-commit

on:
pull_request:
branches: [main]

jobs:
validate-binary:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Check that bin/auto-commit exists
run: |
if [ ! -f "bin/auto-commit" ]; then
echo "[-] bin/auto-commit not found."
exit 1
fi
echo "[+] bin/auto-commit exists."

- name: (Optional) Run binary with --help or version
run: |
./bin/auto-commit --help || echo "Help output not available (optional check)."
40 changes: 40 additions & 0 deletions .github/workflows/c-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Static C Check

on:
pull_request:
branches: [main]

jobs:
c_check:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Cache apt dependencies
uses: actions/cache@v3
with:
path: |
/var/cache/apt
/var/lib/apt/lists
key: ${{ runner.os }}-apt-${{ hashFiles('**/Makefile') }}
restore-keys: |
${{ runner.os }}-apt-

- name: Install tools
run: |
sudo apt-get update
sudo apt-get install -y cppcheck clang clang-tools flawfinder mingw-w64

- name: Cppcheck analysis
run: |
cppcheck --enable=all --inconclusive --force --quiet ./

- name: Clang static analysis
run: |
scan-build --use-cc=x86_64-w64-mingw32-gcc gcc -c ./*.c

- name: Security audit with Flawfinder
run: |
flawfinder ./
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ jobs:

[©thefuture-industries](https://github.com/thefuture-industries)
files: |
./git-auto-commit/git-auto-commit
./bin/auto-commit
./scripts/install-linux-auto-commit.sh
./install-windows-auto-commit.ps1

- name: Create new branch for next version
run: |
Expand Down
22 changes: 21 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,30 @@ BUILDIN_STRINGS = stdlib/strings.c

MAIN_OUT = "$(bindir)/auto-commit"

UNAME_S := $(shell uname -s)

CC = gcc

ifeq ($(OS),Windows_NT)
MKDIR = mkdir $(bindir) || echo "Directory already exists"
REMOVE_EXT = mv $(MAIN_OUT).exe $(MAIN_OUT)
else
MKDIR = mkdir -p $(bindir)
OS_TYPE = $(shell uname -s)
REMOVE_EXT = true
endif

build:
@if not exist $(bindir) mkdir $(bindir)
$(MKDIR)
$(CC) $(BUILDIN_MAIN) -o $(MAIN_OUT) $(BUILDIN_COMMIT) \
$(BUILDIN_DETECT) $(BUILDIN_DIFF) $(BUILDIN_FILE) \
$(BUILDIN_GET_STAGED) $(BUILDIN_STRINGS) $(BUILDIN_GIT_ROOT) \
$(BUILDIN_PARSER)

$(REMOVE_EXT)

buildt:
$(MKDIR)
$(CC) $(BUILDIN_MAIN) -o $(MAIN_OUT) $(BUILDIN_COMMIT) \
$(BUILDIN_DETECT) $(BUILDIN_DIFF) $(BUILDIN_FILE) \
$(BUILDIN_GET_STAGED) $(BUILDIN_STRINGS) $(BUILDIN_GIT_ROOT) \
Expand Down
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
# Git auto-commit
# Git auto-commit - automatic commit generation tool

`git auto-commit` is a simple and powerful tool for automating commits in Git. With it, you will no longer have to think and write committees. `git auto-commit` will do it for you!
Git Auto-Commit is an extension for the Git version control system designed to automatically generate meaningful and context—sensitive commit messages based on changes made to the codebase. The tool simplifies developers' workflows by allowing them to focus on the content of edits rather than on the formulation of descriptions for commits.

This is an open source project, which is covered by the Mit License version 1 (some parts of it are released under other licenses compatible with GPLv2).
The development is conducted as an open source project and is distributed under the MIT license (or other compatible licensing, depending on the implementation). Git Auto-Commit can be integrated into CI/CD pipelines, hook scripts, or used manually via the command line.

Main features:

- Analysis of changes in the work tree and automatic generation of commit messages in natural language.
- Integration with Git via the `git auto` sub-command or configuration of user aliases.
- Support for templates and configurations for configuring the message structure in accordance with project standards (Conventional Commits, Semantic Commit Messages, etc.).
- Scalability: works both in small projects and in large monorepositories.

## Install

You will need two things for installation
### If you're on windows

- If you're on windows
Go to the root of the project and run the command.

```bash
iex ((New-Object Net.WebClient).DownloadString('https://github.com/thefuture-industries/git-auto-commit/blob/main/scripts/auto-commit.ps1?raw=true'))
iex ((New-Object Net.WebClient).DownloadString('https://github.com/thefuture-industries/git-auto-commit/blob/main/scripts/install-windows-auto-commit.ps1?raw=true'))
```

- If you're on linux
### If you're on linux

Go to the root of the project and run the command.

```bash
bash <(curl -s https://github.com/thefuture-industries/git-auto-commit/blob/main/scripts/auto-commit.sh?raw=true)
bash <(curl -s https://github.com/thefuture-industries/git-auto-commit/blob/main/scripts/install-linux-auto-commit.sh?raw=true)
```

## Setting up
Expand All @@ -28,6 +37,6 @@ Everything is ready now, after making changes to the code, just run:

```bash
git add .
git ac
git auto
git push
```
34 changes: 34 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Security Policy

Thanks for helping make Litestar safe for everyone.

## Security

Litestar takes the security of our projects and services seriously, including all of the repositories managed by the [litestar organization](https://github.com/litestar-org).

We will ensure that your finding gets escalated to the appropriate maintainer(s) for remediation.

## Reporting Security Issues

**Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.**

[Click to Open a Security Advisory Privately](https://github.com/litestar-org/litestar/security/advisories/new)

If you believe you have found a security vulnerability in any Litestar-managed repository, please report it to us through coordinated disclosure:

- In the affected repository, browse to the **Security** tab, select **Advisories**, select "Report a vulnerability"
- ![image](https://user-images.githubusercontent.com/45884264/217041010-8fd6b96b-329d-4d8e-8838-9b5bf4e1a78d.png)
- Please do **NOT** create an issue in the affected repository
- Please do **NOT** send a private message to and/or tag the "@maintainer" role on our [Discord server](https://discord.gg/MmcwxztmQb)

Please include as much of the information listed below as you can to help us better understand and resolve the issue:

- The type of issue (e.g., buffer overflow, SQL injection, or cross-site scripting)
- Full paths of source file(s) related to the manifestation of the issue
- The location of the affected source code (tag/branch/commit or direct URL)
- Any special configuration required to reproduce the issue
- Step-by-step instructions to reproduce the issue
- Proof-of-concept or exploit code (if possible)
- Impact of the issue, including how an attacker might exploit the issue

This information will help us triage your report more quickly.
Binary file modified bin/auto-commit
Binary file not shown.
78 changes: 61 additions & 17 deletions commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "define.h"
#include "file.h"

char* build_commit(char funcs[][MAX_FUNC_NAME], int funcs_count) {
char* build_commit(char a_funcs[][MAX_FUNC_NAME], int a_funcs_count, char d_funcs[][MAX_FUNC_NAME], int d_funcs_count) {
int add_count, del_count, rn_count, ch_count;

char** added = ad_f(&add_count);
Expand All @@ -20,18 +20,24 @@ char* build_commit(char funcs[][MAX_FUNC_NAME], int funcs_count) {

commit_message[0] = '\0';

if (funcs_count > 0) {
if (funcs_count == 1) {
strcat(commit_message, "| added ");
strcat(commit_message, funcs[0]);
if (a_funcs_count > 0) {
if (a_funcs_count == 1) {
// strcat(commit_message, "| added ");
if (commit_message[0] != '\0') {
strcat(commit_message, " | added ");
} else {
strcat(commit_message, "added ");
}

strcat(commit_message, a_funcs[0]);
strcat(commit_message, " functionality");
} else {
char* funcs_ptr[MAX_FUNC_COUNT];
for (int i = 0; i < funcs_count; ++i) {
funcs_ptr[i] = funcs[i];
for (int i = 0; i < a_funcs_count; ++i) {
funcs_ptr[i] = a_funcs[i];
}
char* funcs_str = join_strings(funcs_ptr, funcs_count - 1, ", ");
char* last_func = funcs[funcs_count - 1];
char* funcs_str = join_strings(funcs_ptr, a_funcs_count - 1, ", ");
char* last_func = a_funcs[a_funcs_count - 1];

strcat(commit_message, "added ");
strcat(commit_message, funcs_str);
Expand All @@ -45,7 +51,12 @@ char* build_commit(char funcs[][MAX_FUNC_NAME], int funcs_count) {

if (add_count > 0) {
char* added_str = join_strings(added, add_count, ", ");
strcat(commit_message, " | including ");
if (commit_message[0] != '\0') {
strcat(commit_message, " | including ");
} else {
strcat(commit_message, "including ");
}

strcat(commit_message, added_str);

remove_all_spaces(added_str);
Expand All @@ -54,7 +65,12 @@ char* build_commit(char funcs[][MAX_FUNC_NAME], int funcs_count) {

if (del_count > 0) {
char* deleted_str = join_strings(deleted, del_count, ", ");
strcat(commit_message, " | deleted ");
if (commit_message[0] != '\0') {
strcat(commit_message, " | deleted ");
} else {
strcat(commit_message, "deleted ");
}

strcat(commit_message, deleted_str);

remove_all_spaces(deleted_str);
Expand All @@ -63,7 +79,12 @@ char* build_commit(char funcs[][MAX_FUNC_NAME], int funcs_count) {

if (rn_count > 0) {
char* renamed_str = join_strings(renamed, rn_count, ", ");
strcat(commit_message, " | renamed ");
if (commit_message[0] != '\0') {
strcat(commit_message, " | renamed ");
} else {
strcat(commit_message, "renamed ");
}

strcat(commit_message, renamed_str);

remove_all_spaces(renamed_str);
Expand All @@ -72,7 +93,12 @@ char* build_commit(char funcs[][MAX_FUNC_NAME], int funcs_count) {

if (ch_count > 0) {
char* changed_str = join_strings(changed, ch_count, ", ");
strcat(commit_message, " | changed ");
if (commit_message[0] != '\0') {
strcat(commit_message, " | changed ");
} else {
strcat(commit_message, "changed ");
}

strcat(commit_message, changed_str);

remove_all_spaces(changed_str);
Expand All @@ -87,12 +113,12 @@ char* build_commit(char funcs[][MAX_FUNC_NAME], int funcs_count) {
if (strlen(commit_message) > COMMIT_LENGTH) {
free(commit_message);

if (funcs_count > 0) {
if (a_funcs_count > 0) {
char* funcs_ptr[MAX_FUNC_COUNT];
for (int i = 0; i < funcs_count; ++i) {
funcs_ptr[i] = funcs[i];
for (int i = 0; i < a_funcs_count; ++i) {
funcs_ptr[i] = a_funcs[i];
}
char* funcs_str = join_strings(funcs_ptr, funcs_count, ", ");
char* funcs_str = join_strings(funcs_ptr, a_funcs_count, ", ");
char* short_commit = malloc(strlen("added ") + strlen(funcs_str) + 12);
if (!short_commit) return NULL;
sprintf(short_commit, "added %s functionality", funcs_str);
Expand Down Expand Up @@ -143,6 +169,24 @@ char* build_commit(char funcs[][MAX_FUNC_NAME], int funcs_count) {
}
}

if (d_funcs_count > 0) {
char* d_ptrs[MAX_FUNC_COUNT];
for (int i = 0; i < d_funcs_count; ++i) {
d_ptrs[i] = d_funcs[i];
}

char* d_str = join_strings(d_ptrs, d_funcs_count, ", ");
const char* suffix = " | deleted functionality: ";
size_t extra_len = strlen(suffix) + strlen(d_str);

if (strlen(commit_message) + extra_len < COMMIT_LENGTH) {
strcat(commit_message, suffix);
strcat(commit_message, d_str);
}

free(d_str);
}

remove_all_spaces(commit_message);
return commit_message;
}
Expand Down
2 changes: 1 addition & 1 deletion commit.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef COMMIT_H
#define COMMIT_H

char* build_commit(char funcs[][MAX_FUNC_NAME], int funcs_count);
char* build_commit(char a_funcs[][MAX_FUNC_NAME], int a_funcs_count, char d_funcs[][MAX_FUNC_NAME], int d_funcs_count);

int git_commit(const char* message);

Expand Down
Loading
Loading