Skip to content

Commit 98b63f2

Browse files
authored
Merge pull request #26 from Cyber-Syntax:refactor/design-pattern
Refactor/design pattern
2 parents f6a89d3 + ef2f8c4 commit 98b63f2

File tree

13 files changed

+1015
-671
lines changed

13 files changed

+1015
-671
lines changed

.github/copilot-instructions.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Python Coding Rules
2+
3+
- Always add comments.
4+
- Follow PEP 8 style guidelines for code formatting.
5+
- Use meaningful variable and function names in snake_case.
6+
- Use UPPER_CASE for constants.
7+
- Use CamelCase for class names.
8+
- Add docstrings to all functions, classes, and modules following the Google style guide.
9+
- Use type hints to indicate parameter and return types.
10+
- Use f-strings for string formatting instead of older methods.
11+
- Implement proper exception handling with specific exception types.
12+
- Use logging instead of print statements for recording key actions and errors.
13+
- Store configuration in separate files (e.g., YAML, JSON, or .env) rather than hardcoding in scripts.
14+
- Always check return values from functions that may fail.
15+
- Write descriptive error messages that help diagnose the problem.
16+
- Keep functions focused on a single responsibility.
17+
- Use proper scoping for variables (avoid globals).

.github/workflows/main.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Create Release from CHANGELOG
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "CHANGELOG.md" # Only trigger when CHANGELOG.md is updated
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Extract latest version and notes
20+
id: changelog
21+
run: |
22+
# Extract the first version number from CHANGELOG.md
23+
VERSION=$(grep -m 1 '^## v' CHANGELOG.md | sed 's/^## \(v[0-9.]*[0-9]\(-[a-zA-Z0-9]*\)*\).*/\1/')
24+
echo "version=$VERSION" >> $GITHUB_OUTPUT
25+
26+
# Extract notes for this version (everything between this version header and the next version header)
27+
NOTES=$(awk -v ver="$VERSION" '
28+
BEGIN { found=0; capture=0; notes=""; }
29+
$0 ~ "^## " ver { found=1; capture=1; next; }
30+
$0 ~ /^## v/ && capture==1 { capture=0; }
31+
capture==1 { notes = notes $0 "\n"; }
32+
END { print notes; }
33+
' CHANGELOG.md)
34+
35+
# Save notes to output with correct GitHub multiline syntax
36+
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
37+
echo "notes<<$EOF" >> $GITHUB_OUTPUT
38+
echo "$NOTES" >> $GITHUB_OUTPUT
39+
echo "$EOF" >> $GITHUB_OUTPUT
40+
41+
# For debugging
42+
echo "Found version: $VERSION"
43+
echo "Release notes excerpt: $(echo "$NOTES" | head -3)..."
44+
45+
- name: Check for existing release
46+
id: check_release
47+
run: |
48+
VERSION=${{ steps.changelog.outputs.version }}
49+
if gh release view $VERSION &>/dev/null; then
50+
echo "Release already exists: $VERSION"
51+
echo "exists=true" >> $GITHUB_OUTPUT
52+
else
53+
echo "No existing release found for: $VERSION"
54+
echo "exists=false" >> $GITHUB_OUTPUT
55+
fi
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
59+
- name: Create zip archive
60+
if: steps.check_release.outputs.exists == 'false'
61+
run: zip -r AutoTarCompress-${{ steps.changelog.outputs.version }}.zip ./ -x "*.git*" ".github/*"
62+
63+
- name: Create GitHub Release
64+
if: steps.check_release.outputs.exists == 'false'
65+
uses: softprops/action-gh-release@v1
66+
with:
67+
tag_name: ${{ steps.changelog.outputs.version }}
68+
name: "Release ${{ steps.changelog.outputs.version }}"
69+
body: ${{ steps.changelog.outputs.notes }}
70+
draft: false
71+
prerelease: ${{ contains(steps.changelog.outputs.version, '-') }}
72+
files: AutoTarCompress-${{ steps.changelog.outputs.version }}.zip
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,5 @@ dmypy.json
135135
# vscode
136136
.vscode/
137137

138-
# dirs_to_backup
139-
dirs_to_backup*
138+
# ruff
139+
.ruff_cache

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
## v0.3.1-beta
5+
### Changes
6+
# BREAKING CHANGES
7+
Current config file location moved to `~/.config/autotarcompress/config.json`. Please review example config file and update it for your needs.
8+
9+
- feat!: Use XDG Base Directory specifications.
10+
- fix: endless backup command issue
11+
- refactor: make class for context manager
12+
- chore: format fix
13+
- chore: pytproject.toml and requirements.txt update
14+
- refactor!: add command design pattern

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,25 @@
5151
```
5252

5353
5. Config File Handling:
54-
- To customize your backup settings, you can use a `config.json` file. This file allows you to specify:
55-
- Backup folder location, Directories to back up, Directories to ignore, Number of tar.xz and tar.xz.enc files to keep
54+
55+
- To customize your backup settings, you need to use a `config.json` file. This file allows you to specify:
56+
- Backup folder location, Directories to back up, Directories to ignore, Number of tar.xz and tar.xz.enc files to keep
5657
- **Creating a Config File:**
5758
- You have two options:
58-
1. **Run the script and follow the on-screen instructions**. This will guide you through creating a `config.json` file.
59-
2. **Use an example config file (Optional)**:
60-
- Copy the example configuration from `config_files_example/config.json`
61-
- Paste it into your `backup_folder/config_files/config.json` location (e.g `~/Documents/backup-for-cloud/config_files/config.json`)
62-
- Modify it as needed
59+
1. **Use an example config file (Recommended)**:
60+
- Copy the example configuration from `config_files_example/config.json`
61+
- Paste it into your `~/Documents/project_configs/AutoTarCompress/config_files/config.json` location
62+
- Modify it as needed
63+
2. **Run the script and follow the on-screen instructions**.
64+
- This will guide you through creating a `config.json` file.
6365

64-
3. Start the script:
66+
6. Start the script:
6567

6668
```bash
6769
python3 main.py
6870
```
6971

70-
4. Follow the on-screen instructions.
72+
7. Follow the on-screen instructions.
7173

7274
---
7375

README.tr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
1. **Senaryoyu çalıştır ve ekrandaki talimatları takip et**. Bu size bir `config.json` dosyası oluşturmayı kılavuzlayacaktır.
5959
2. **Örnek Ayar Dosyasını Kullan (Opsiyonel)**:
6060
- Örnek konfigürasyonunuzu `config_files_example/config.json` konumundan kopyalayın
61-
- Bu dosyayı `backup_folder/config_files/config.json` konumuna yapıştırın (örn. `~/Documents/backup-for-cloud/config_files/config.json`)
61+
- Bu dosyayı `~/.config/autotarcompress/config.json` konumuna yapıştırın (örn. `~/Documents/backup-for-cloud/config_files/config.json`)
6262
- Gereksinim duyduğunuz kadarını değiştirin
6363

6464
3. Script'i başlatın:

TODO.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

config_files_example/config.json

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"backup_folder": "~/Documents/backup-for-cloud/",
3+
"config_dir": "~/.config/autotarcompress",
4+
"keep_backup": 1,
5+
"keep_enc_backup": 1,
6+
"dirs_to_backup": [
7+
"~/Pictures",
8+
"~/Documents",
9+
"~/.config/autotarcompress",
10+
"~/.mozilla/firefox/sqwu9kep.default-release",
11+
"~/.config/BraveSoftware/Brave-Browser/Default",
12+
"~/dotfiles",
13+
"~/bare"
14+
],
15+
"ignore_list": [
16+
"~/Documents/appimages",
17+
"~/Documents/backup-for-cloud",
18+
"~/Documents/.stversions",
19+
"node_modules",
20+
".venv",
21+
"__pycache__",
22+
".ruff_cache"
23+
],
24+
"last_backup": null
25+
}

0 commit comments

Comments
 (0)