{"id":21560465,"url":"https://github.com/lu0/git-worktree-airflow","last_synced_at":"2025-03-18T04:27:16.553Z","repository":{"id":132823527,"uuid":"474544309","full_name":"lu0/git-worktree-airflow","owner":"lu0","description":"Solves Airflow DAG management in bare Git repos, loading correct DAGs upon branch switch.","archived":false,"fork":false,"pushed_at":"2024-02-18T18:40:08.000Z","size":69,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-24T11:13:27.266Z","etag":null,"topics":["airflow","bare-repo","bare-repository","git","git-hooks","git-workflow","git-worktree","hacktoberfest","pre-commit","pre-commit-hook"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lu0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-03-27T05:31:14.000Z","updated_at":"2024-10-05T14:32:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"db127722-6c7c-4b89-b684-9576ca746205","html_url":"https://github.com/lu0/git-worktree-airflow","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lu0%2Fgit-worktree-airflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lu0%2Fgit-worktree-airflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lu0%2Fgit-worktree-airflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lu0%2Fgit-worktree-airflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lu0","download_url":"https://codeload.github.com/lu0/git-worktree-airflow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244155696,"owners_count":20407403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["airflow","bare-repo","bare-repository","git","git-hooks","git-workflow","git-worktree","hacktoberfest","pre-commit","pre-commit-hook"],"created_at":"2024-11-24T09:15:04.266Z","updated_at":"2025-03-18T04:27:16.530Z","avatar_url":"https://github.com/lu0.png","language":"Shell","readme":"`git-worktree-airflow`\n---\n\nThis repository contains a post-checkout hook script useful to manage Airflow\n`dags_folder`s pointing to bare repositories.\n\nCalled after a successful `git checkout`, this hook script\ncreates a file `.airflowignore` in the root directory of a bare repository,\nlisting all files and directories except for the worktree directory of the last\n*checked out* tree-ish (branch, tag or commit); then the **Airflow UI will show\nonly the DAGs contained in this directory**.\n\n\nTable of Contents\n---\n- [Installation](#installation)\n  - [Using `pre-commit`](#using-pre-commit)\n  - [Manual](#manual)\n- [Usage](#usage)\n  - [Recommended option: Using `git-worktree-wrapper`](#recommended-option-using-git-worktree-wrapper)\n  - [Alternative option: Using vanilla `git`](#alternative-option-using-vanilla-git)\n  - [Examples](#examples)\n\n# Installation\n\n## Using [`pre-commit`](https://pre-commit.com)\n\nActivate this post-checkout hook by adding it to your `.pre-commit-config.yaml`:\n\n```sh\nrepos:\n  - repo: https://github.com/lu0/git-worktree-airflow\n    rev: v1.1.3\n    hooks:\n      - id: airflow-worktree\n        name: Update .airflowignore to load DAGs from worktree\n        stages: [post-checkout]\n        always_run: true\n        verbose: true\n```\n\nAnd installing it:\n\n```sh\npre-commit install --hook-type post-checkout\n```\n\n## Manual\n\n- Copy or link the script `select-airflow-worktree.sh` into the `hooks`\ndirectory of your `dags_folder` (which should be a bare repository), and rename\nit to `post-checkout`.\n\n- Example:\n\n\u003cpre\u003e\u003ccode\u003eln -srf select-airflow-worktree.sh \u003cb\u003e/path/to/your/dags_folder\u003c/b\u003e/hooks/post-checkout\u003c/pre\u003e\u003c/code\u003e\n\n*Note*: Make the script executable with `chmod +x post-checkout` if you\n***copied** the script instead of linking it.\n\n\n# Usage\n\n## Recommended option: Using [`git-worktree-wrapper`](https://github.com/lu0/git-worktree-wrapper)\n\n- Install [`git-worktree-wrapper`](https://github.com/lu0/git-worktree-wrapper).\n\n- Checkout into a tree-ish object. The hook will be triggered automatically.\n\n    ```sh\n    $ git checkout \u003ctree-ish\u003e\n\n        .airflowignore updated to load DAGs from \u003ctree-ish\u003e\n    ```\n\n## Alternative option: Using vanilla `git`\n\n1. First ***cd*** into the worktree directory of a tree-ish\n    ```language\n    $ cd /path/to/the/root/directory/of/the/bare/repo\n    $ cd tree-ish\n    ```\n\n1. Then trigger the hook\n\n    ```sh\n    $ git checkout \u003ctree-ish\u003e\n\n        .airflowignore updated to load DAGs from \u003ctree-ish\u003e\n    ```\n\n## Examples\n\nLet's say we have a `dags` folder pointing to a bare repository in `~/dags` with the following structure:\n\n*Note: Directories and files common to bare repositories are hidden.*\n\n```sh\n. dags\n├── development\n│   ├── dag_1.py\n│   └── dag_2.py\n├── feature\n│   └── dag_4\n│       ├── dag_1.py\n│       ├── dag_2.py\n│       ├── dag_3.py\n│       ├── dag_4.py\n│       └── examples\n│           ├── example_dag_1.py\n│           └── example_dag_2.py\n└── master\n    ├── dag_1.py\n    ├── dag_2.py\n    ├── dag_3.py\n    └── examples\n        ├── example_dag_1.py\n        └── example_dag_2.py\n```\n\nAnd you want the Airflow UI to show the DAGs contained in the `feature/dag_4` worktree.\n\n- If you are using\n[`git-worktree-wrapper`](https://github.com/lu0/git-worktree-wrapper) and\n[`pre-commit`](#using-pre-commit), just checkout into the tree-ish. You can\ncheckout from any nested worktree.\n\n    ```sh\n    $ git checkout feature/dag_4\n    ```\n    ![hook showcase to feature/dag_4](assets/hook-showcase-0.png)\n\n\n- If you are using vanilla `git`:\n\n    ```language\n    $ cd ~/dags\n    $ cd feature/dag_4\n    $ git checkout feature/dag_4\n\n        .airflowignore updated to load DAGs from feature/dag_4\n    ```\n\nEither way, the post-checkout hook will create a file named `.airflowignore` with the following contents:\n\n*Note: Directories and files common to bare repositories are hidden.*\n\n```sh\ndevelopment\nmaster\n```\n\nIf you trigger the hook in tree-ish `development`, `.airflowignore` will look like this:\n\n*Note: Directories and files common to bare repositories are hidden.*\n\n```sh\nfeature\nmaster\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flu0%2Fgit-worktree-airflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flu0%2Fgit-worktree-airflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flu0%2Fgit-worktree-airflow/lists"}