Skip to content

Commit

Permalink
Clean initial state
Browse files Browse the repository at this point in the history
  • Loading branch information
Clean History Script committed Dec 19, 2024
0 parents commit b271851
Show file tree
Hide file tree
Showing 7 changed files with 703 additions and 0 deletions.
104 changes: 104 additions & 0 deletions .github/workflows/latex.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: My CV

on:
push:
branches:
- main

permissions:
contents: write

jobs:
build-pdf:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Compile LaTeX document
uses: xu-cheng/latex-action@v3
with:
root_file: frontend.tex

- name: Upload PDF artifact
uses: actions/upload-artifact@v4
with:
name: PDF
path: frontend.pdf

commit-pdf:
needs: build-pdf
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download PDF artifact
uses: actions/download-artifact@v4
with:
name: PDF
path: .

- name: Commit PDF
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add -f frontend.pdf
git commit -m "Update PDF" || echo "No changes to commit"
git push
create-release:
needs: commit-pdf
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download PDF artifact
uses: actions/download-artifact@v4
with:
name: PDF
path: .

- name: List files (for debugging)
run: ls -la

- name: Check if tag exists
id: check_tag
run: |
if git ls-remote --tags origin refs/tags/v1.0.0 | grep -q 'v1.0.0'; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Delete existing release and tag
if: steps.check_tag.outputs.exists == 'true'
uses: dev-drprasad/[email protected]
with:
tag_name: v1.0.0
delete_release: true
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v1.0.0
release_name: Release v1.0.0
draft: false
prerelease: false

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: frontend.pdf
asset_name: frontend.pdf
asset_content_type: application/pdf
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*.aux
*.log
*.out
*.toc
*.bbl
*.blg
*.fdb_latexmk
*.fls
*.synctex.gz
*.pdf
*.tex.pdf
*.tips
*.upa
*.upb
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["james-yu.latex-workshop"]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"[latex]": {
"editor.defaultFormatter": "James-Yu.latex-workshop"
},
"latex-workshop.formatting.latex": "latexindent"
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[![cv-banner](https://github.com/user-attachments/assets/1881cb9e-9a1b-44ac-a06c-d1d60eb1c599)](https://leila.sh/cv/frontend.pdf)
76 changes: 76 additions & 0 deletions clean-git-history.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash

# Exit on any error
set -e

# Store current branch name
CURRENT_BRANCH=$(git branch --show-current)

# Store original git config
ORIGINAL_USER_NAME=$(git config user.name)
ORIGINAL_USER_EMAIL=$(git config user.email)

# Function to restore git config
restore_git_config() {
echo "Restoring original git config..."
git config --local user.name "$ORIGINAL_USER_NAME"
git config --local user.email "$ORIGINAL_USER_EMAIL"
}

# Set trap to restore git config on script exit (success, error, or interrupt)
trap restore_git_config EXIT

# Set temporary git config
git config --local user.name "Clean History Script"
git config --local user.email "[email protected]"

echo "Current branch: $CURRENT_BRANCH"

# Stash all changes including untracked files
echo "Stashing current changes..."
git stash push -u -m "before cleaning history"

# Check if clean-history branch exists and delete it if it does
if git show-ref --verify --quiet refs/heads/clean-history; then
echo "Removing existing clean-history branch..."
git branch -D clean-history
fi

# Create new clean-history branch from current branch
echo "Creating new clean-history branch..."
git checkout -b clean-history

# Merge the blinded branch if it exists
if git show-ref --verify --quiet refs/heads/blinded; then
echo "Merging blinded branch into clean-history..."
git merge blinded --no-commit --no-ff
# Commit the merge
echo "Committing merge..."
git commit -m "Merge blinded branch into clean-history"
fi

# Get the hash of the first commit
FIRST_COMMIT=$(git rev-list --max-parents=0 HEAD)

# Soft reset to the first commit
echo "Resetting to first commit..."
git reset --soft $FIRST_COMMIT

# Undo the first commit while keeping changes (equivalent to VSCode undo)
# This is done by resetting to before the first commit while keeping changes
echo "Undoing first commit while keeping changes..."
git update-ref -d HEAD

# Create new initial commit with all current changes
echo "Creating new clean commit..."
git add .
git commit -m "Clean initial state"


# Force push to remote and set upstream
echo "Force pushing to remote..."
git push -uf clean HEAD:main

echo "Success! Clean history has been pushed to clean/main"
git checkout $CURRENT_BRANCH
echo "To recover your stashed changes: git stash pop"
Loading

0 comments on commit b271851

Please sign in to comment.