Compare commits

...

No commits in common. "TomekM-23.05.2024" and "dev" have entirely different histories.

12 changed files with 180 additions and 8023 deletions

16
conf.json Normal file
View File

@ -0,0 +1,16 @@
{
"user": "borysr",
"email": "borysr@gmail.com",
"remotes": [
{
"name": "r",
"protocol": "http",
"domain": "qstack.pl",
"port": "3000",
"token_name": "t",
"token": "8ee3f1b7980197aeceadee3cf4d980f817d44f06",
"group": "1i-2023",
"project": "homework"
}
]
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -7,6 +7,7 @@ int strlen(char *s) {
return p - s;
}
void strcpy(char *s, char *t)
{
while (*s++ = *t++);
@ -65,14 +66,13 @@ char *simple_strtok(char *str, const char *delims) {
static char *static_str = (char *) NULL; // Przechowuje wskaźnik do bieżącej pozycji w ciągu
// Jeśli przekazano nowy ciąg, zaktualizuj static_str
if (str != NULL) {
if (str == NULL) {
return (char *) NULL; // str nie wskazuje na zdanie !!!
}
static_str = str;
}
// Jeśli static_str jest NULL, zwróć NULL
if (static_str == NULL) {
return (char *) NULL;
}
// " .,mpabi"
// ^
// Pomiń początkowe delimitery
while (*static_str && is_delim(*static_str, delims)) {
@ -102,21 +102,62 @@ char *simple_strtok(char *str, const char *delims) {
return token_start;
}
char buf[100];
struct model * p = (struct model *) buf; //p[1]
////func alg
//in: ptr to date
//return: count of words
int alg (const char * ptr) {
return 1;
}
char bufer[ALLOCSIZE];
strcpy(bufer, (char *)ptr);
const char *delims = " ,.!?:;\n\t";
int8_t count = 0;
char *token = simple_strtok(bufer, delims);
while (token != (char *)NULL) {
p[count].str = token;
p[count].len = strlen(token);
token = simple_strtok((char *)NULL, delims);
count++;
}
return count;
}
int main() {
char *str = "If wantered relation no surprise of all";
struct model * ptr = (struct model *) alloc (LEN);
alg(str);
asm ("nop");
return 1;
}
// wynik tego kodu:
// p[0].str = If
// p[0].len = 2
// p[1].str = wantered
// p[1].len = 8
// p[2].str = relation
// p[2].len = 8
// p[3].str = no
// p[3].len = 2
// p[4].str = surprise
// p[4].len = 8
// p[5].str = of
// p[5].len = 2
// p[6].str = all
// p[6].len = 3

Binary file not shown.

Binary file not shown.

BIN
cpp/prog

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

2
gra.txt Normal file
View File

@ -0,0 +1,2 @@
https://www.mediafire.com/file/c5d9ad65bxiln6o/MojaGra1.zip/file

111
igit-borys.py Normal file
View File

@ -0,0 +1,111 @@
import argparse
import json
import sys
import subprocess
import os
from datetime import datetime
DEFAULT_CONFIG = {
"user": "borysr",
"email": "borysr@gmail.com",
"remotes": [{
"name": "r", # Zaktualizowano z "default" na "mpabi"
"protocol": "http",
"domain": "qstack.pl",
"port": "3000",
"token_name": "t",
"token": "8ee3f1b7980197aeceadee3cf4d980f817d44f06",
"group": "1i-2023",
"project": "homework"
}]
}
def load_or_create_config(config_file, args):
config_exists = os.path.exists(config_file) and os.stat(config_file).st_size != 0
if config_exists:
with open(config_file, 'r') as file:
config = json.load(file)
else:
config = DEFAULT_CONFIG.copy()
# Znajdź istniejące zdalne repozytorium o podanej nazwie
remote = next((remote for remote in config['remotes'] if remote['name'] == args.remote), None)
# Jeśli istnieje zdalne repozytorium i podano argumenty związane z konfiguracją zdalnego repozytorium
if remote:
for field in ['protocol', 'domain', 'port', 'token_name', 'token', 'group', 'project']:
# Aktualizuj tylko, jeśli argument został jawnie podany
if getattr(args, field, None) is not None:
remote[field] = getattr(args, field)
# Jeśli zdalne repozytorium nie istnieje, ale podano nazwę, tworzymy nowe zdalne repozytorium
elif args.remote:
new_remote = {'name': args.remote}
for field in ['protocol', 'domain', 'port', 'token_name', 'token', 'group', 'project']:
new_remote[field] = getattr(args, field, DEFAULT_CONFIG['remotes'][0].get(field, ''))
if new_remote[field] == None:
new_remote[field] = DEFAULT_CONFIG['remotes'][0].get(field, '')
config['remotes'].append(new_remote)
# Aktualizuj informacje o użytkowniku i email, tylko jeśli zostały podane
if getattr(args, 'user', None):
config['user'] = args.user
if getattr(args, 'email_domain', None):
config['email'] = f"{args.user}@{args.email_domain}"
# Zapisz zmodyfikowaną konfigurację
with open(config_file, 'w') as file:
json.dump(config, file, indent=4)
return config
def init_git_repo(config):
user_name = config['user']
user_email = config['email']
branch_name = f"{user_name}-{datetime.now().strftime('%Y-%m-%d')}"
if subprocess.run(["git", "rev-parse", "--git-dir"], stderr=subprocess.DEVNULL).returncode != 0:
subprocess.run(["git", "init"])
subprocess.run(["git", "config", "user.name", user_name])
subprocess.run(["git", "config", "user.email", user_email])
subprocess.run(["git", "checkout", "-b", branch_name])
print("Git repository initialized.")
else:
print("Already inside a Git repository. Skipping initialization.")
remotesFromList = str(subprocess.run(["git", "remote", "-v"], capture_output=True).stdout)
remotesFromList = remotesFromList.replace('b\'', "").replace('\'', "").split('\\n')
for rm in remotesFromList:
name = rm.split("\\t")[0]
subprocess.run(["git", "remote", "remove", name], stderr=subprocess.DEVNULL)
for remote in config['remotes']:
remote_url = f"{remote['protocol']}://{remote['token_name']}:{remote['token']}@{remote['domain']}:{remote['port']}/{remote['group']}/{remote['project']}"
# Usunięcie i ponowne dodanie zdalnego repozytorium, jeśli jest zaktualizowane
#subprocess.run(["git", "remote", "remove", remote['name']], stderr=subprocess.DEVNULL)
subprocess.run(["git", "remote", "add", remote['name'], remote_url])
print(f"Remote '{remote['name']}' added or updated.")
def main():
parser = argparse.ArgumentParser(description="Git repository initializer with custom configuration.")
parser.add_argument("--user", help="User name")
parser.add_argument("--email_domain", help="Email domain")
parser.add_argument("--config", help="Path to the JSON config file", default="conf.json")
parser.add_argument("--remote", help="Name of the remote to add or update")
parser.add_argument("--protocol", help="Remote protocol")
parser.add_argument("--domain", help="Remote domain")
parser.add_argument("--port", help="Remote port")
parser.add_argument("--token_name", help="Remote token name")
parser.add_argument("--token", help="Remote token")
parser.add_argument("--group", help="Group name")
parser.add_argument("--project", help="Project name")
args = parser.parse_args()
config = load_or_create_config(args.config, args)
init_git_repo(config)
print("Git repository initialized and configured based on the provided configuration.")
if __name__ == "__main__":
main()