├── .github └── workflows │ ├── ci.yml │ └── release.yml ├── .gitignore ├── .goreleaser.yaml ├── LICENSE ├── Makefile ├── README.md ├── common ├── author.go ├── autosync.go ├── awake_notifier_darwin.go ├── awake_notifier_linux.go ├── awake_notifier_windows.go ├── commit.go ├── commit_test.go ├── config │ ├── config.go │ ├── v1.go │ └── v1_test.go ├── fetch.go ├── fetch_test.go ├── ignore.go ├── ignore_test.go ├── push.go ├── rebase.go ├── rebase_test.go ├── service.go ├── testdata │ ├── ignore │ │ ├── .gitignore │ │ ├── .gitted │ │ │ ├── HEAD │ │ │ ├── branches │ │ │ │ └── .gitignore │ │ │ ├── config │ │ │ ├── description │ │ │ ├── index │ │ │ ├── info │ │ │ │ └── refs │ │ │ ├── objects │ │ │ │ └── pack │ │ │ │ │ ├── pack-6084461925de24b5672557d115a4eff8b2d92326.idx │ │ │ │ │ └── pack-6084461925de24b5672557d115a4eff8b2d92326.pack │ │ │ ├── packed-refs │ │ │ └── refs │ │ │ │ ├── heads │ │ │ │ └── .gitignore │ │ │ │ └── tags │ │ │ │ └── .gitignore │ │ └── 1.md │ ├── multiple_file_change │ │ ├── .gitted │ │ │ ├── COMMIT_EDITMSG │ │ │ ├── HEAD │ │ │ ├── branches │ │ │ │ └── .gitignore │ │ │ ├── config │ │ │ ├── description │ │ │ ├── index │ │ │ ├── info │ │ │ │ └── refs │ │ │ ├── logs │ │ │ │ ├── HEAD │ │ │ │ └── refs │ │ │ │ │ └── heads │ │ │ │ │ └── master │ │ │ ├── objects │ │ │ │ ├── info │ │ │ │ │ ├── commit-graph │ │ │ │ │ └── packs │ │ │ │ └── pack │ │ │ │ │ ├── pack-8bd23478afc278bb9d444418db77fa24b756f8b8.idx │ │ │ │ │ └── pack-8bd23478afc278bb9d444418db77fa24b756f8b8.pack │ │ │ ├── packed-refs │ │ │ └── refs │ │ │ │ ├── heads │ │ │ │ └── .gitignore │ │ │ │ └── tags │ │ │ │ └── .gitignore │ │ ├── 1.md │ │ └── dirB │ │ │ └── 3.md │ ├── new_file │ │ ├── .gitted │ │ │ ├── HEAD │ │ │ ├── branches │ │ │ │ └── .gitignore │ │ │ ├── config │ │ │ ├── description │ │ │ ├── index │ │ │ ├── objects │ │ │ │ └── pack │ │ │ │ │ ├── pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.idx │ │ │ │ │ └── pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.pack │ │ │ ├── packed-refs │ │ │ └── refs │ │ │ │ ├── heads │ │ │ │ └── .gitignore │ │ │ │ └── tags │ │ │ │ └── .gitignore │ │ ├── 1.md │ │ └── 2.md │ ├── no_changes │ │ ├── .gitted │ │ │ ├── HEAD │ │ │ ├── branches │ │ │ │ └── .gitignore │ │ │ ├── config │ │ │ ├── description │ │ │ ├── index │ │ │ ├── objects │ │ │ │ └── pack │ │ │ │ │ ├── pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.idx │ │ │ │ │ └── pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.pack │ │ │ ├── packed-refs │ │ │ └── refs │ │ │ │ ├── heads │ │ │ │ └── .gitignore │ │ │ │ └── tags │ │ │ │ └── .gitignore │ │ └── 1.md │ ├── one_file_change │ │ ├── .gitted │ │ │ ├── HEAD │ │ │ ├── branches │ │ │ │ └── .gitignore │ │ │ ├── config │ │ │ ├── description │ │ │ ├── index │ │ │ ├── objects │ │ │ │ └── pack │ │ │ │ │ ├── pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.idx │ │ │ │ │ └── pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.pack │ │ │ ├── packed-refs │ │ │ └── refs │ │ │ │ ├── heads │ │ │ │ └── .gitignore │ │ │ │ └── tags │ │ │ │ └── .gitignore │ │ └── 1.md │ ├── rebase_both_commits │ │ ├── .gitted │ │ │ ├── HEAD │ │ │ ├── branches │ │ │ │ └── .gitignore │ │ │ ├── config │ │ │ ├── description │ │ │ ├── index │ │ │ ├── objects │ │ │ │ ├── 57 │ │ │ │ │ └── 79561afa9d074ae8d20974861c54757429aca9 │ │ │ │ ├── 5b │ │ │ │ │ └── 2421e1ef4d7f32306709aab06b1a6c02294b30 │ │ │ │ ├── b8 │ │ │ │ │ └── 626c4cff2849624fb67f87cd0ad72b163671ad │ │ │ │ ├── bb │ │ │ │ │ └── 42c22f4d5ce6083275b82e129a4b7868913015 │ │ │ │ ├── e6 │ │ │ │ │ └── 9de29bb2d1d6434b8b29ae775ad8c2e48c5391 │ │ │ │ └── pack │ │ │ │ │ ├── pack-5acce72f5df296705a9b2e13dc0581d7f0b26f96.idx │ │ │ │ │ └── pack-5acce72f5df296705a9b2e13dc0581d7f0b26f96.pack │ │ │ ├── packed-refs │ │ │ └── refs │ │ │ │ ├── heads │ │ │ │ └── .gitignore │ │ │ │ └── tags │ │ │ │ └── .gitignore │ │ ├── 1.md │ │ └── 2.md │ ├── rebase_both_commits_conflict │ │ ├── .gitted │ │ │ ├── HEAD │ │ │ ├── branches │ │ │ │ └── .gitignore │ │ │ ├── config │ │ │ ├── description │ │ │ ├── index │ │ │ ├── info │ │ │ │ └── refs │ │ │ ├── objects │ │ │ │ ├── 5b │ │ │ │ │ └── 2421e1ef4d7f32306709aab06b1a6c02294b30 │ │ │ │ ├── e6 │ │ │ │ │ └── 9de29bb2d1d6434b8b29ae775ad8c2e48c5391 │ │ │ │ ├── info │ │ │ │ │ ├── commit-graph │ │ │ │ │ └── packs │ │ │ │ └── pack │ │ │ │ │ ├── pack-fd52ab0ce127a1919ff8c45b06c172528a4e8fb7.idx │ │ │ │ │ └── pack-fd52ab0ce127a1919ff8c45b06c172528a4e8fb7.pack │ │ │ ├── packed-refs │ │ │ └── refs │ │ │ │ ├── heads │ │ │ │ └── .gitignore │ │ │ │ └── tags │ │ │ │ └── .gitignore │ │ ├── 1.md │ │ ├── 2.md │ │ └── 3.md │ ├── rebase_local_commits │ │ ├── .gitted │ │ │ ├── HEAD │ │ │ ├── branches │ │ │ │ └── .gitignore │ │ │ ├── config │ │ │ ├── description │ │ │ ├── index │ │ │ ├── info │ │ │ │ └── refs │ │ │ ├── objects │ │ │ │ └── pack │ │ │ │ │ ├── pack-6ed5aab84549686dd1639003c49f7f7aede63325.idx │ │ │ │ │ └── pack-6ed5aab84549686dd1639003c49f7f7aede63325.pack │ │ │ ├── packed-refs │ │ │ └── refs │ │ │ │ ├── heads │ │ │ │ └── .gitignore │ │ │ │ └── tags │ │ │ │ └── .gitignore │ │ ├── 1.md │ │ └── 2.md │ ├── rebase_nothing │ │ ├── .gitted │ │ │ ├── FETCH_HEAD │ │ │ ├── HEAD │ │ │ ├── branches │ │ │ │ └── .gitignore │ │ │ ├── config │ │ │ ├── description │ │ │ ├── index │ │ │ ├── logs │ │ │ │ └── refs │ │ │ │ │ └── remotes │ │ │ │ │ └── origin │ │ │ │ │ └── master │ │ │ ├── objects │ │ │ │ └── pack │ │ │ │ │ ├── pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.idx │ │ │ │ │ └── pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.pack │ │ │ ├── packed-refs │ │ │ └── refs │ │ │ │ ├── heads │ │ │ │ └── .gitignore │ │ │ │ ├── remotes │ │ │ │ └── origin │ │ │ │ │ └── master │ │ │ │ └── tags │ │ │ │ └── .gitignore │ │ └── 1.md │ ├── rebase_parent │ │ ├── .gitted │ │ │ ├── HEAD │ │ │ ├── branches │ │ │ │ └── .gitignore │ │ │ ├── config │ │ │ ├── description │ │ │ ├── index │ │ │ ├── objects │ │ │ │ └── pack │ │ │ │ │ ├── pack-0e97b284249125dd68802efc8e497badec0ab786.idx │ │ │ │ │ └── pack-0e97b284249125dd68802efc8e497badec0ab786.pack │ │ │ ├── packed-refs │ │ │ └── refs │ │ │ │ ├── heads │ │ │ │ └── .gitignore │ │ │ │ └── tags │ │ │ │ └── .gitignore │ │ ├── 1.md │ │ └── 3.md │ ├── rebase_remote_commits │ │ ├── .gitted │ │ │ ├── HEAD │ │ │ ├── branches │ │ │ │ └── .gitignore │ │ │ ├── config │ │ │ ├── description │ │ │ ├── index │ │ │ ├── info │ │ │ │ └── refs │ │ │ ├── objects │ │ │ │ └── pack │ │ │ │ │ ├── pack-6c99d95700f1ca8eaa8f19957b0c70a80a1d0b72.idx │ │ │ │ │ └── pack-6c99d95700f1ca8eaa8f19957b0c70a80a1d0b72.pack │ │ │ ├── packed-refs │ │ │ └── refs │ │ │ │ ├── heads │ │ │ │ └── .gitignore │ │ │ │ └── tags │ │ │ │ └── .gitignore │ │ └── 1.md │ ├── simple_fetch │ │ ├── .gitted │ │ │ ├── HEAD │ │ │ ├── branches │ │ │ │ └── .gitignore │ │ │ ├── config │ │ │ ├── description │ │ │ ├── index │ │ │ ├── objects │ │ │ │ └── pack │ │ │ │ │ ├── pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.idx │ │ │ │ │ └── pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.pack │ │ │ ├── packed-refs │ │ │ └── refs │ │ │ │ ├── heads │ │ │ │ └── .gitignore │ │ │ │ └── tags │ │ │ │ └── .gitignore │ │ └── 1.md │ └── vim_swap_file │ │ ├── .1.md.swp │ │ ├── .gitted │ │ ├── HEAD │ │ ├── branches │ │ │ └── .gitignore │ │ ├── config │ │ ├── description │ │ ├── index │ │ ├── objects │ │ │ └── pack │ │ │ │ ├── pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.idx │ │ │ │ └── pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.pack │ │ ├── packed-refs │ │ └── refs │ │ │ ├── heads │ │ │ └── .gitignore │ │ │ └── tags │ │ │ └── .gitignore │ │ └── 1.md └── watch.go ├── completions ├── bash_autocomplete ├── powershell_autocomplete.ps1 └── zsh_autocomplete ├── daemon.go ├── daemon ├── .gitignore └── main.go ├── go.mod ├── go.sum ├── main.go └── todo.md /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | pull_request: 5 | workflow_dispatch: 6 | push: 7 | branches: 8 | - "master" 9 | 10 | jobs: 11 | test: 12 | name: Test 13 | runs-on: ubuntu-20.04 14 | env: 15 | CGO_ENABLED: 0 16 | EMAIL: test@example.com 17 | steps: 18 | - uses: actions/checkout@v2 19 | - uses: actions/setup-go@v2 20 | with: 21 | go-version: 1.18 22 | - name: Setup Git Identity 23 | run: | 24 | git config --global user.email "test@example.com" 25 | git config --global user.name "GitHub CI" 26 | - run: go test ./... 27 | 28 | lint: 29 | name: Lint 30 | runs-on: ubuntu-20.04 31 | env: 32 | CGO_ENABLED: 0 33 | steps: 34 | - uses: actions/checkout@v2 35 | - uses: actions/setup-go@v2 36 | with: 37 | go-version: 1.18 38 | - uses: golangci/golangci-lint-action@v2 39 | with: 40 | version: v1.46.1 41 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: goreleaser 2 | 3 | on: 4 | push: 5 | tags: 6 | - "*" 7 | 8 | jobs: 9 | goreleaser: 10 | runs-on: macos-latest 11 | steps: 12 | - name: Checkout 13 | uses: actions/checkout@v2 14 | with: 15 | fetch-depth: 0 16 | - name: Set up Go 17 | uses: actions/setup-go@v2 18 | with: 19 | go-version: 1.18 20 | - name: Install Snapcraft 21 | uses: samuelmeuli/action-snapcraft@v1 22 | - name: snapcraft-login 23 | env: 24 | SNAPCRAFT_LOGIN: ${{ secrets.SNAPCRAFT_LOGIN }} 25 | run: | 26 | snapcraft login --with <(echo "$SNAPCRAFT_LOGIN" | base64 -d) 27 | - name: Run GoReleaser 28 | uses: goreleaser/goreleaser-action@v2 29 | if: startsWith(github.ref, 'refs/tags/') 30 | with: 31 | distribution: goreleaser 32 | version: latest 33 | args: release --rm-dist 34 | env: 35 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 36 | TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }} 37 | SNAPCRAFT_LOGIN: ${{ secrets.SNAPCRAFT_LOGIN }} 38 | FURY_TOKEN: ${{ secrets.FURY_PUSH_TOKEN }} 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | git-auto-sync 2 | 3 | dist/ 4 | -------------------------------------------------------------------------------- /.goreleaser.yaml: -------------------------------------------------------------------------------- 1 | project_name: git-auto-sync 2 | 3 | before: 4 | hooks: 5 | - go mod tidy 6 | - go generate ./... 7 | builds: 8 | - binary: git-auto-sync 9 | id: git-auto-sync 10 | env: 11 | - CGO_ENABLED=0 12 | goos: 13 | - linux 14 | - windows 15 | goarch: 16 | - amd64 17 | - arm 18 | - arm64 19 | 20 | - binary: git-auto-sync-daemon 21 | id: git-auto-sync-daemon 22 | dir: daemon 23 | env: 24 | - CGO_ENABLED=0 25 | goos: 26 | - linux 27 | - windows 28 | goarch: 29 | - amd64 30 | - arm 31 | - arm64 32 | 33 | # Macos build needs to be built on macos 34 | # https://github.com/rjeczalik/notify/issues/177 35 | - binary: git-auto-sync 36 | id: git-auto-sync-macos 37 | env: 38 | - CGO_ENABLED=1 39 | - CC=clang 40 | - CXX=clang++ 41 | goos: 42 | - darwin 43 | goarch: 44 | - amd64 45 | - arm64 46 | 47 | - binary: git-auto-sync-daemon 48 | id: git-auto-sync-daemon-macos 49 | dir: daemon 50 | env: 51 | - CGO_ENABLED=1 52 | - CC=clang 53 | - CXX=clang++ 54 | goos: 55 | - darwin 56 | goarch: 57 | - amd64 58 | - arm64 59 | archives: 60 | - replacements: 61 | darwin: Darwin 62 | linux: Linux 63 | windows: Windows 64 | 386: i386 65 | amd64: x86_64 66 | files: 67 | - LICENSE 68 | - README.md 69 | - completions/bash_autocomplete 70 | - completions/zsh_autocomplete 71 | checksum: 72 | name_template: "checksums.txt" 73 | snapshot: 74 | name_template: "{{ incpatch .Version }}-next" 75 | changelog: 76 | sort: asc 77 | filters: 78 | exclude: 79 | - "^docs:" 80 | - "^test:" 81 | brews: 82 | - name: git-auto-sync 83 | homepage: https://github.com/GitJournal/git-auto-sync 84 | license: Apache-2.0 85 | tap: 86 | owner: GitJournal 87 | name: homebrew-tap 88 | token: "{{ .Env.TAP_GITHUB_TOKEN }}" 89 | install: | 90 | bin.install "git-auto-sync" 91 | bin.install "git-auto-sync-daemon" 92 | bash_completion.install "completions/bash_autocomplete" 93 | zsh_completion.install "completions/zsh_autocomplete" 94 | 95 | snapcrafts: 96 | - publish: true 97 | summary: Automatically sync your changes in any git repository 98 | description: | 99 | GitAutoSync is a simple command line program to automatically commit changes 100 | to your git repo, and always keep that repo up to date. This way you can use 101 | any editor with your text files, and never need to worry about committing 102 | and remembering to push and pull changes. 103 | confinement: classic 104 | license: Apache-2.0 105 | base: core20 106 | grade: stable 107 | apps: 108 | git-auto-sync: 109 | command: git-auto-sync 110 | completer: completions/bash_autocomplete 111 | 112 | nfpms: 113 | - id: linux_packages 114 | file_name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" 115 | description: | 116 | GitAutoSync is a simple command line program to automatically commit changes 117 | to your git repo, and always keep that repo up to date. This way you can use 118 | any editor with your text files, and never need to worry about committing 119 | and remembering to push and pull changes. 120 | homepage: https://github.com/GitJournal/git-auto-sync 121 | license: Apache-2.0 122 | maintainer: Vishesh Handa 123 | formats: 124 | - deb 125 | - rpm 126 | dependencies: 127 | - git 128 | 129 | publishers: 130 | - name: fury.io 131 | ids: 132 | - linux_packages 133 | dir: "{{ dir .ArtifactPath }}" 134 | cmd: curl -F package=@{{ .ArtifactName }} https://{{ .Env.FURY_TOKEN }}@push.fury.io/vhanda/ 135 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: lint 2 | 3 | lint: 4 | golangci-lint run 5 | 6 | test: 7 | go test ./... 8 | 9 | install: 10 | go install . 11 | cd daemon && go build -o git-auto-sync-daemon . 12 | cd daemon && mv git-auto-sync-daemon ${GOPATH}/bin/ 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Git Auto Sync 2 | 3 | GitAutoSync is a simple command line program to automatically commit changes 4 | to your git repo, and always keep that repo up to date. This way you can use any editor with your text files, and never need to worry about 5 | comitting and remembering to push and pull changes. 6 | 7 | ## Installation 8 | 9 | * OSX - `brew install GitJournal/tap/git-auto-sync` 10 | * Linux - 11 | - Ubuntu/Debian - 12 | 13 | ```bash 14 | sudo echo "deb [trusted=yes] https://apt.fury.io/vhanda/ /" | sudo tee /etc/apt/sources.list.d/git-auto-sync.list 15 | sudo apt-get update 16 | sudo apt-get install -y git-auto-sync 17 | ``` 18 | - Fedora/RPM - 19 | 20 | ```bash 21 | sudo echo -e "[git-auto-sync]\nname=Git-Auto-Sync\nbaseurl=https://yum.fury.io/vhanda/\nenabled=1\ngpgcheck=0" | sudo tee /etc/yum.repos.d/git-auto-sync.repo 22 | sudo yum update 23 | sudo yum install -y git-auto-sync 24 | ``` 25 | - Arch Linux - Please write an AUR package and open a PR for this. You're an Arch User. You got this. 26 | - Other - Download the [latest release](https://github.com/GitJournal/git-auto-sync/releases/latest) 27 | * Windows - Download the [latest release](https://github.com/GitJournal/git-auto-sync/releases/latest) 28 | 29 | ## How to use? 30 | 31 | GitAutoSync comes with a manual and daemon mode. It's recommended to start with the manual 32 | mode to ensure authentication is working correctly. It internally just calls the `git` executable 33 | so, if that works, `git-auto-sync` should just work. 34 | 35 | You can test it out by running `git-auto-sync sync` to commit, pull, rebase and push any changes. 36 | If there are no changes, it will just attempt to pull, rebase and push. 37 | 38 | Once you're satisfied that `git-auto-sync` is working for you. You can run `git-auto-sync daemon add ` to start a background daemon which will continously monitor that repo for any changes 39 | in the file system and accordingly sync the changes. 40 | 41 | This daemon will be automatically started as a system process. 42 | 43 | You can check if it is running `git-auto-sync daemon status` 44 | 45 | ### Background Daemon 46 | 47 | The background daemon will be started / stopped automatically if there are any repos to watch in `git-auto-sync daemon ls`. 48 | This process will monitor the filesystem, poll every 10 minutes, and additionally try to sync on resuming from a suspend. The latter 49 | two are done to pick up changes from the remote. 50 | 51 | ### Merge Conflicts 52 | 53 | GitAutoSync current only supports rebases, and doesn't yet attempt to do a merge. In the case of a 54 | rebase conflict, it will abort and stop syncing that repo. It will send a system notification 55 | to inform you of the conflict. 56 | 57 | ### Ignored Files 58 | 59 | It currently ignores all hidden files, files ignored by git, and additional temporary swap files 60 | created by vim, emacs and similar editors. 61 | 62 | ## Similar Projects 63 | 64 | - [Obsidian Git](https://github.com/denolehov/obsidian-git) 65 | - [VS Code GitDoc](https://marketplace.visualstudio.com/items?itemName=vsls-contrib.gitdoc) 66 | - [Git Annex](https://git-annex.branchable.com/) 67 | - [Git Sync](https://github.com/simonthum/git-sync) 68 | -------------------------------------------------------------------------------- /common/author.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "errors" 5 | "os/exec" 6 | 7 | "github.com/ztrue/tracerr" 8 | ) 9 | 10 | var errNoGitAuthorEmail = errors.New("Missing git author email") 11 | var errNoGitAuthorName = errors.New("Missing git author name") 12 | 13 | func ensureGitAuthor(repoConfig RepoConfig) error { 14 | _, err := GitCommand(repoConfig, []string{"config", "user.email"}) 15 | if err != nil { 16 | var exerr *exec.ExitError 17 | if errors.As(err, &exerr) && exerr.ExitCode() == 1 { 18 | return errNoGitAuthorEmail 19 | } 20 | return tracerr.Wrap(err) 21 | } 22 | 23 | _, err = GitCommand(repoConfig, []string{"config", "user.name"}) 24 | if err != nil { 25 | var exerr *exec.ExitError 26 | if errors.As(err, &exerr) && exerr.ExitCode() == 1 { 27 | return errNoGitAuthorName 28 | } 29 | return tracerr.Wrap(err) 30 | } 31 | 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /common/autosync.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/gen2brain/beeep" 7 | "github.com/ztrue/tracerr" 8 | ) 9 | 10 | // FIXME: Add logs for when we commit, pull, and push 11 | func AutoSync(repoConfig RepoConfig) error { 12 | var err error 13 | err = ensureGitAuthor(repoConfig) 14 | if err != nil { 15 | return tracerr.Wrap(err) 16 | } 17 | 18 | err = commit(repoConfig) 19 | if err != nil { 20 | return tracerr.Wrap(err) 21 | } 22 | 23 | err = fetch(repoConfig) 24 | if err != nil { 25 | return tracerr.Wrap(err) 26 | } 27 | 28 | err = rebase(repoConfig) 29 | if err != nil { 30 | if errors.Is(err, errRebaseFailed) { 31 | repoPath := repoConfig.RepoPath 32 | err := beeep.Alert("Git Auto Sync - Conflict", "Could not rebase for - "+repoPath, "assets/warning.png") 33 | if err != nil { 34 | return tracerr.Wrap(err) 35 | } 36 | } 37 | // How should we continue? 38 | // - Keep sending the notification each time? 39 | // - Or something a bit better? 40 | return tracerr.Wrap(err) 41 | } 42 | 43 | err = push(repoConfig) 44 | if err != nil { 45 | return tracerr.Wrap(err) 46 | } 47 | 48 | // -> do a merge 49 | // -> push the changes 50 | 51 | return nil 52 | } 53 | -------------------------------------------------------------------------------- /common/awake_notifier_darwin.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import "github.com/prashantgupta24/mac-sleep-notifier/notifier" 4 | 5 | type AwakeNotifierDarwn struct { 6 | n *notifier.Notifier 7 | } 8 | 9 | func NewAwakeNotifier() (*AwakeNotifierDarwn, error) { 10 | n := notifier.GetInstance() 11 | 12 | return &AwakeNotifierDarwn{n: n}, nil 13 | } 14 | 15 | func (a *AwakeNotifierDarwn) Start(out chan bool) error { 16 | suspendResumeNotifier := a.n.Start() 17 | 18 | go func() { 19 | for { 20 | activity := <-suspendResumeNotifier 21 | if activity.Type == notifier.Awake { 22 | out <- true 23 | } 24 | } 25 | }() 26 | 27 | return nil 28 | } 29 | -------------------------------------------------------------------------------- /common/awake_notifier_linux.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | type AwakeNotifierEmpty struct{} 4 | 5 | func (AwakeNotifierEmpty) Start(chan bool) error { 6 | return nil 7 | } 8 | 9 | func NewAwakeNotifier() (AwakeNotifier, error) { 10 | return AwakeNotifierEmpty{}, nil 11 | } 12 | -------------------------------------------------------------------------------- /common/awake_notifier_windows.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | type AwakeNotifierWindows struct{} 4 | 5 | func (AwakeNotifierWindows) Start(chan bool) error { 6 | return nil 7 | } 8 | 9 | func NewAwakeNotifier() (AwakeNotifier, error) { 10 | return AwakeNotifierWindows{}, nil 11 | } 12 | -------------------------------------------------------------------------------- /common/commit.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "os" 7 | "os/exec" 8 | "sort" 9 | "strings" 10 | 11 | "github.com/ztrue/tracerr" 12 | git "gopkg.in/src-d/go-git.v4" 13 | ) 14 | 15 | func commit(repoConfig RepoConfig) error { 16 | repoPath := repoConfig.RepoPath 17 | repo, err := git.PlainOpenWithOptions(repoPath, &git.PlainOpenOptions{DetectDotGit: true}) 18 | if err != nil { 19 | return tracerr.Wrap(err) 20 | } 21 | 22 | w, err := repo.Worktree() 23 | if err != nil { 24 | return tracerr.Wrap(err) 25 | } 26 | 27 | status, err := w.Status() 28 | if err != nil { 29 | return tracerr.Wrap(err) 30 | } 31 | 32 | hasChanges := false 33 | commitMsg := []string{} 34 | for filePath, fileStatus := range status { 35 | if fileStatus.Worktree == git.Unmodified && fileStatus.Staging == git.Unmodified { 36 | continue 37 | } 38 | 39 | ignore, err := ShouldIgnoreFile(repoPath, filePath) 40 | if err != nil { 41 | return tracerr.Wrap(err) 42 | } 43 | 44 | if ignore { 45 | continue 46 | } 47 | 48 | hasChanges = true 49 | _, err = w.Add(filePath) 50 | if err != nil { 51 | return tracerr.Wrap(err) 52 | } 53 | 54 | msg := "" 55 | if fileStatus.Worktree == git.Untracked && fileStatus.Staging == git.Untracked { 56 | msg += "?? " 57 | } else { 58 | msg += " " + string(fileStatus.Worktree) + " " 59 | } 60 | msg += filePath 61 | commitMsg = append(commitMsg, msg) 62 | } 63 | 64 | sort.Strings(commitMsg) 65 | msg := strings.Join(commitMsg, "\n") 66 | 67 | if !hasChanges { 68 | return nil 69 | } 70 | 71 | _, err = GitCommand(repoConfig, []string{"commit", "-m", msg}) 72 | if err != nil { 73 | return tracerr.Wrap(err) 74 | } 75 | 76 | return nil 77 | } 78 | 79 | func GitCommand(repoConfig RepoConfig, args []string) (bytes.Buffer, error) { 80 | repoPath := repoConfig.RepoPath 81 | 82 | var outb, errb bytes.Buffer 83 | 84 | cmd := "git" 85 | if repoConfig.GitExec != "" { 86 | cmd = repoConfig.GitExec 87 | } 88 | 89 | statusCmd := exec.Command(cmd, args...) 90 | statusCmd.Dir = repoPath 91 | statusCmd.Stdout = &outb 92 | statusCmd.Stderr = &errb 93 | statusCmd.Env = toEnvString(repoConfig) 94 | err := statusCmd.Run() 95 | 96 | if hasEnvVariable(os.Environ(), "SSH_AUTH_SOCK") && !hasEnvVariable(repoConfig.Env, "SSH_AUTH_SOCK") { 97 | fmt.Println("WARNING: SSH_AUTH_SOCK env variable isn't being passed") 98 | } 99 | 100 | if err != nil { 101 | fullCmd := "git " + strings.Join(args, " ") 102 | err := tracerr.Errorf("%w: Command: %s\nEnv: %s\nStdOut: %s\nStdErr: %s", err, fullCmd, statusCmd.Env, outb.String(), errb.String()) 103 | return outb, err 104 | } 105 | return outb, nil 106 | } 107 | 108 | func toEnvString(repoConfig RepoConfig) []string { 109 | vals := repoConfig.Env 110 | vals = append(vals, repoConfig.Env...) 111 | 112 | for _, s := range os.Environ() { 113 | parts := strings.Split(s, "=") 114 | k := parts[0] 115 | if k == "HOME" { 116 | vals = append(vals, s) 117 | } 118 | } 119 | 120 | return vals 121 | } 122 | 123 | func hasEnvVariable(all []string, name string) bool { 124 | for _, s := range all { 125 | parts := strings.Split(s, "=") 126 | k := parts[0] 127 | if k == name { 128 | return true 129 | } 130 | } 131 | return false 132 | } 133 | -------------------------------------------------------------------------------- /common/commit_test.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "io/ioutil" 5 | "os" 6 | "path/filepath" 7 | "testing" 8 | 9 | cp "github.com/otiai10/copy" 10 | git "gopkg.in/src-d/go-git.v4" 11 | "gopkg.in/src-d/go-git.v4/plumbing" 12 | 13 | "gotest.tools/v3/assert" 14 | ) 15 | 16 | func PrepareFixture(t *testing.T, name string) RepoConfig { 17 | newRepoPath, err := ioutil.TempDir(os.TempDir(), name) 18 | assert.NilError(t, err) 19 | 20 | fixturePath := filepath.Join("testdata", name) 21 | err = cp.Copy(fixturePath, newRepoPath) 22 | assert.NilError(t, err) 23 | 24 | err = os.Rename(filepath.Join(newRepoPath, ".gitted"), filepath.Join(newRepoPath, ".git")) 25 | assert.NilError(t, err) 26 | 27 | repoConfig, err := NewRepoConfig(newRepoPath) 28 | assert.NilError(t, err) 29 | 30 | return repoConfig 31 | } 32 | 33 | func Test_NoChanges(t *testing.T) { 34 | repoConfig := PrepareFixture(t, "no_changes") 35 | 36 | err := commit(repoConfig) 37 | assert.NilError(t, err) 38 | 39 | r, err := git.PlainOpen(repoConfig.RepoPath) 40 | assert.NilError(t, err) 41 | 42 | head, err := r.Head() 43 | assert.NilError(t, err) 44 | 45 | assert.Equal(t, head.Hash(), plumbing.NewHash("28cc969d97ddb7640f5e1428bbc8f2947d1ffd57")) 46 | } 47 | 48 | func HasHeadCommit(t *testing.T, repoPath string, hash string, msg string) { 49 | r, err := git.PlainOpen(repoPath) 50 | assert.NilError(t, err) 51 | 52 | head, err := r.Head() 53 | assert.NilError(t, err) 54 | 55 | assert.Assert(t, head.Hash() != plumbing.NewHash(hash)) 56 | 57 | commit, err := r.CommitObject(head.Hash()) 58 | assert.NilError(t, err) 59 | 60 | parent, err := commit.Parent(0) 61 | assert.NilError(t, err) 62 | assert.Equal(t, parent.ID(), plumbing.NewHash(hash)) 63 | assert.Equal(t, commit.Message, msg) 64 | } 65 | 66 | func Test_NewFile(t *testing.T) { 67 | repoConfig := PrepareFixture(t, "new_file") 68 | 69 | err := commit(repoConfig) 70 | assert.NilError(t, err) 71 | 72 | HasHeadCommit(t, repoConfig.RepoPath, "28cc969d97ddb7640f5e1428bbc8f2947d1ffd57", "?? 2.md\n") 73 | } 74 | 75 | func Test_OneFileChange(t *testing.T) { 76 | repoConfig := PrepareFixture(t, "one_file_change") 77 | 78 | err := commit(repoConfig) 79 | assert.NilError(t, err) 80 | 81 | HasHeadCommit(t, repoConfig.RepoPath, "28cc969d97ddb7640f5e1428bbc8f2947d1ffd57", " M 1.md\n") 82 | } 83 | 84 | func Test_VimSwapFile(t *testing.T) { 85 | repoConfig := PrepareFixture(t, "vim_swap_file") 86 | 87 | err := commit(repoConfig) 88 | assert.NilError(t, err) 89 | 90 | r, err := git.PlainOpen(repoConfig.RepoPath) 91 | assert.NilError(t, err) 92 | 93 | head, err := r.Head() 94 | assert.NilError(t, err) 95 | 96 | assert.Equal(t, head.Hash(), plumbing.NewHash("28cc969d97ddb7640f5e1428bbc8f2947d1ffd57")) 97 | } 98 | 99 | func Test_MultipleFileChange(t *testing.T) { 100 | repoConfig := PrepareFixture(t, "multiple_file_change") 101 | 102 | err := commit(repoConfig) 103 | assert.NilError(t, err) 104 | 105 | HasHeadCommit(t, repoConfig.RepoPath, "7058b6b292ee3d1382670334b5f29570a1117ef1", ` D dirA/2.md 106 | M 1.md 107 | ?? dirB/3.md 108 | `) 109 | } 110 | -------------------------------------------------------------------------------- /common/config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type Config = ConfigV1 4 | 5 | func Read() (*Config, error) { 6 | return ReadV1() 7 | } 8 | 9 | func Write(config *Config) error { 10 | return WriteV1(config) 11 | } 12 | -------------------------------------------------------------------------------- /common/config/v1.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "encoding/json" 5 | "os" 6 | "path/filepath" 7 | 8 | "github.com/kirsle/configdir" 9 | "github.com/ztrue/tracerr" 10 | ) 11 | 12 | type ConfigV1 struct { 13 | Repos []string `json:"repos"` 14 | Envs []string `json:"envs"` 15 | } 16 | 17 | func ReadV1() (*ConfigV1, error) { 18 | configPath := configdir.LocalConfig("git-auto-sync") 19 | err := configdir.MakePath(configPath) 20 | if err != nil { 21 | return nil, tracerr.Wrap(err) 22 | } 23 | 24 | configFile := filepath.Join(configPath, "config.json") 25 | config := ConfigV1{} 26 | 27 | if _, err = os.Stat(configFile); os.IsNotExist(err) { 28 | return &config, nil 29 | } else { 30 | // Load the existing file. 31 | fh, err := os.Open(configFile) 32 | if err != nil { 33 | return nil, tracerr.Wrap(err) 34 | } 35 | defer fh.Close() 36 | 37 | decoder := json.NewDecoder(fh) 38 | err = decoder.Decode(&config) 39 | if err != nil { 40 | return nil, tracerr.Wrap(err) 41 | } 42 | } 43 | 44 | return &config, nil 45 | } 46 | 47 | func WriteV1(config *ConfigV1) error { 48 | configPath := configdir.LocalConfig("git-auto-sync") 49 | err := configdir.MakePath(configPath) 50 | if err != nil { 51 | return tracerr.Wrap(err) 52 | } 53 | 54 | configFile := filepath.Join(configPath, "config.json") 55 | 56 | fh, err := os.Create(configFile) 57 | if err != nil { 58 | return tracerr.Wrap(err) 59 | } 60 | defer fh.Close() 61 | 62 | encoder := json.NewEncoder(fh) 63 | err = encoder.Encode(&config) 64 | if err != nil { 65 | return tracerr.Wrap(err) 66 | } 67 | 68 | return nil 69 | } 70 | -------------------------------------------------------------------------------- /common/config/v1_test.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "io/ioutil" 5 | "os" 6 | "testing" 7 | 8 | "github.com/kirsle/configdir" 9 | "gotest.tools/v3/assert" 10 | ) 11 | 12 | func setup(t *testing.T, name string) { 13 | newConfigDir, err := ioutil.TempDir(os.TempDir(), "config_"+name) 14 | assert.NilError(t, err) 15 | t.Setenv("XDG_CONFIG_HOME", newConfigDir) 16 | t.Setenv("HOME", newConfigDir) 17 | 18 | configdir.Refresh() 19 | } 20 | 21 | func Test_SimpleWriteReadV1(t *testing.T) { 22 | setup(t, "SimpleWriteRead") 23 | 24 | c := &ConfigV1{ 25 | Repos: []string{"/home/xyz/hello"}, 26 | Envs: []string{"SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.74ZznY1v1F/Listeners"}, 27 | } 28 | err := WriteV1(c) 29 | assert.NilError(t, err) 30 | 31 | c2, err := ReadV1() 32 | assert.NilError(t, err) 33 | 34 | assert.DeepEqual(t, c, c2) 35 | } 36 | 37 | func Test_ReadEmptyV1(t *testing.T) { 38 | setup(t, "ReadEmpty") 39 | 40 | c, err := ReadV1() 41 | assert.NilError(t, err) 42 | assert.Assert(t, len(c.Repos) == 0) 43 | } 44 | -------------------------------------------------------------------------------- /common/fetch.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "github.com/ztrue/tracerr" 5 | git "gopkg.in/src-d/go-git.v4" 6 | ) 7 | 8 | func fetch(repoConfig RepoConfig) error { 9 | repoPath := repoConfig.RepoPath 10 | r, err := git.PlainOpenWithOptions(repoPath, &git.PlainOpenOptions{DetectDotGit: true}) 11 | if err != nil { 12 | return tracerr.Wrap(err) 13 | } 14 | 15 | remotes, err := r.Remotes() 16 | if err != nil { 17 | return tracerr.Wrap(err) 18 | } 19 | 20 | for _, remote := range remotes { 21 | remoteName := remote.Config().Name 22 | 23 | _, err := GitCommand(repoConfig, []string{"fetch", remoteName}) 24 | if err != nil { 25 | return tracerr.Wrap(err) 26 | } 27 | } 28 | 29 | return nil 30 | } 31 | -------------------------------------------------------------------------------- /common/fetch_test.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "bytes" 5 | "io/ioutil" 6 | "os" 7 | "path/filepath" 8 | "testing" 9 | 10 | cp "github.com/otiai10/copy" 11 | git "gopkg.in/src-d/go-git.v4" 12 | "gopkg.in/src-d/go-git.v4/plumbing" 13 | "gotest.tools/v3/assert" 14 | ) 15 | 16 | func PrepareMultiFixtures(t *testing.T, name string, deps []string) RepoConfig { 17 | newTestDataPath, err := ioutil.TempDir(os.TempDir(), "mutli_fixture") 18 | assert.NilError(t, err) 19 | 20 | for _, name := range deps { 21 | fixturePath := filepath.Join("testdata", name) 22 | newPath := filepath.Join(newTestDataPath, name) 23 | err = cp.Copy(fixturePath, newPath) 24 | assert.NilError(t, err) 25 | 26 | err = os.Rename(filepath.Join(newPath, ".gitted"), filepath.Join(newPath, ".git")) 27 | assert.NilError(t, err) 28 | } 29 | 30 | newRepoConfig := PrepareFixture(t, name) 31 | FixFixtureGitConfig(t, newRepoConfig.RepoPath, newTestDataPath) 32 | 33 | return newRepoConfig 34 | } 35 | 36 | func FixFixtureGitConfig(t *testing.T, newRepoPath string, testDataPath string) { 37 | // Fix remote paths 38 | dotGitPath := filepath.Join(newRepoPath, ".git") 39 | gitConfigFilePath := filepath.Join(dotGitPath, "config") 40 | input, err := ioutil.ReadFile(gitConfigFilePath) 41 | assert.NilError(t, err) 42 | 43 | output := bytes.Replace(input, []byte("$TESTDATA$"), []byte(testDataPath), -1) 44 | 45 | err = ioutil.WriteFile(gitConfigFilePath, output, 0666) 46 | assert.NilError(t, err) 47 | } 48 | 49 | func Test_SimpleFetch(t *testing.T) { 50 | repoConfig := PrepareMultiFixtures(t, "simple_fetch", []string{"multiple_file_change"}) 51 | 52 | err := fetch(repoConfig) 53 | assert.NilError(t, err) 54 | 55 | r, err := git.PlainOpen(repoConfig.RepoPath) 56 | assert.NilError(t, err) 57 | 58 | head, err := r.Head() 59 | assert.NilError(t, err) 60 | 61 | assert.Equal(t, head.Hash(), plumbing.NewHash("28cc969d97ddb7640f5e1428bbc8f2947d1ffd57")) 62 | 63 | ref, err := r.Reference(plumbing.NewRemoteReferenceName("origin1", "master"), true) 64 | assert.NilError(t, err) 65 | 66 | assert.Equal(t, ref.Hash(), plumbing.NewHash("7058b6b292ee3d1382670334b5f29570a1117ef1")) 67 | } 68 | -------------------------------------------------------------------------------- /common/ignore.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "os" 5 | "path" 6 | "path/filepath" 7 | "strings" 8 | 9 | "github.com/ztrue/tracerr" 10 | git "gopkg.in/src-d/go-git.v4" 11 | "gopkg.in/src-d/go-git.v4/plumbing/format/gitignore" 12 | ) 13 | 14 | func ShouldIgnoreFile(repoPath string, filePath string) (bool, error) { 15 | if !filepath.IsAbs(filePath) { 16 | filePath = path.Join(repoPath, filePath) 17 | } 18 | 19 | fileName := filepath.Base(filePath) 20 | var isTempFile = strings.HasSuffix(fileName, ".swp") || // vim 21 | strings.HasPrefix(fileName, "~") || // emacs 22 | strings.HasSuffix(fileName, "~") // kate 23 | 24 | if isTempFile { 25 | return true, nil 26 | } 27 | 28 | relativePath := filePath[len(repoPath)+1:] 29 | if strings.HasPrefix(relativePath, ".git/") { 30 | return true, nil 31 | } 32 | 33 | empty, err := isEmptyFile(filePath) 34 | if err != nil { 35 | return false, tracerr.Wrap(err) 36 | } 37 | if empty { 38 | return true, nil 39 | } 40 | 41 | return isFileIgnoredByGit(repoPath, filePath) 42 | } 43 | 44 | func isFileIgnoredByGit(repoPath string, filePath string) (bool, error) { 45 | repo, err := git.PlainOpenWithOptions(repoPath, &git.PlainOpenOptions{DetectDotGit: true}) 46 | if err != nil { 47 | return false, tracerr.Wrap(err) 48 | } 49 | 50 | w, err := repo.Worktree() 51 | if err != nil { 52 | return false, tracerr.Wrap(err) 53 | } 54 | 55 | patterns, err := gitignore.ReadPatterns(w.Filesystem, nil) 56 | if err != nil { 57 | return false, tracerr.Wrap(err) 58 | } 59 | 60 | patterns = append(patterns, w.Excludes...) 61 | m := gitignore.NewMatcher(patterns) 62 | 63 | return m.Match([]string{filePath}, false), err 64 | } 65 | 66 | func isEmptyFile(filePath string) (bool, error) { 67 | stat, err := os.Stat(filePath) 68 | 69 | if err != nil { 70 | if os.IsNotExist(err) { 71 | return false, nil 72 | } 73 | return false, err 74 | } 75 | 76 | return stat.Size() == 0, nil 77 | } 78 | -------------------------------------------------------------------------------- /common/ignore_test.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "testing" 5 | 6 | "gotest.tools/v3/assert" 7 | ) 8 | 9 | func Test_SimpleIgnore(t *testing.T) { 10 | repoPath := PrepareFixture(t, "ignore").RepoPath 11 | 12 | ignore, err := isFileIgnoredByGit(repoPath, "1.txt") 13 | assert.NilError(t, err) 14 | assert.Equal(t, ignore, true) 15 | 16 | ignore, err = isFileIgnoredByGit(repoPath, "2.md") 17 | assert.NilError(t, err) 18 | assert.Equal(t, ignore, false) 19 | } 20 | 21 | func Test_HiddenFilesIgnore(t *testing.T) { 22 | repoPath := PrepareFixture(t, "ignore").RepoPath 23 | 24 | ignore, err := ShouldIgnoreFile(repoPath, ".hidden") 25 | assert.NilError(t, err) 26 | assert.Equal(t, ignore, false) 27 | } 28 | -------------------------------------------------------------------------------- /common/push.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "github.com/ztrue/tracerr" 5 | ) 6 | 7 | func push(repoConfig RepoConfig) error { 8 | bi, err := fetchBranchInfo(repoConfig.RepoPath) 9 | if err != nil { 10 | return tracerr.Wrap(err) 11 | } 12 | 13 | if bi.UpstreamBranch == "" || bi.UpstreamRemote == "" { 14 | return nil 15 | } 16 | 17 | _, err = GitCommand(repoConfig, []string{"push", bi.UpstreamRemote, bi.UpstreamBranch}) 18 | if err != nil { 19 | return tracerr.Wrap(err) 20 | } 21 | 22 | return nil 23 | } 24 | -------------------------------------------------------------------------------- /common/rebase.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | "os/exec" 7 | "path" 8 | 9 | "github.com/ztrue/tracerr" 10 | git "gopkg.in/src-d/go-git.v4" 11 | "gopkg.in/src-d/go-git.v4/plumbing" 12 | ) 13 | 14 | var errRebaseFailed = errors.New("git rebase failed") 15 | 16 | func rebase(repoConfig RepoConfig) error { 17 | repoPath := repoConfig.RepoPath 18 | bi, err := fetchBranchInfo(repoPath) 19 | if err != nil { 20 | return tracerr.Wrap(err) 21 | } 22 | 23 | _, rebaseErr := GitCommand(repoConfig, []string{"rebase", bi.UpstreamRemote + "/" + bi.UpstreamBranch}) 24 | if rebaseErr != nil { 25 | rebaseInProgress, err := isRebasing(repoPath) 26 | if err != nil { 27 | return tracerr.Wrap(err) 28 | } 29 | 30 | var exerr *exec.ExitError 31 | if errors.As(rebaseErr, &exerr) && exerr.ExitCode() == 1 && rebaseInProgress { 32 | _, err := GitCommand(repoConfig, []string{"rebase", "--abort"}) 33 | if err != nil { 34 | return tracerr.Wrap(err) 35 | } 36 | return errRebaseFailed 37 | } 38 | return tracerr.Wrap(err) 39 | } 40 | 41 | return nil 42 | } 43 | 44 | func exists(name string) (bool, error) { 45 | _, err := os.Stat(name) 46 | if err == nil { 47 | return true, nil 48 | } 49 | if errors.Is(err, os.ErrNotExist) { 50 | return false, nil 51 | } 52 | return false, err 53 | } 54 | 55 | type branchInfo struct { 56 | CurrentBranch string 57 | UpstreamRemote string 58 | UpstreamBranch string 59 | } 60 | 61 | func fetchBranchInfo(repoPath string) (branchInfo, error) { 62 | repo, err := git.PlainOpenWithOptions(repoPath, &git.PlainOpenOptions{DetectDotGit: true}) 63 | if err != nil { 64 | return branchInfo{}, tracerr.Wrap(err) 65 | } 66 | 67 | config, err := repo.Config() 68 | if err != nil { 69 | return branchInfo{}, tracerr.Wrap(err) 70 | } 71 | 72 | ref, err := repo.Reference(plumbing.HEAD, false) 73 | if err != nil { 74 | return branchInfo{}, tracerr.Wrap(err) 75 | } 76 | 77 | currentBranchName := ref.Target().Short() 78 | branchConfig := config.Branches[currentBranchName] 79 | if branchConfig == nil { 80 | // No tracking branch, nothing to do 81 | return branchInfo{CurrentBranch: currentBranchName}, nil 82 | } 83 | 84 | return branchInfo{ 85 | CurrentBranch: currentBranchName, 86 | UpstreamRemote: branchConfig.Remote, 87 | UpstreamBranch: branchConfig.Merge.Short(), 88 | }, nil 89 | } 90 | 91 | func isRebasing(repoPath string) (bool, error) { 92 | ra, err := exists(path.Join(repoPath, ".git", "rebase-apply")) 93 | if err != nil { 94 | return false, tracerr.Wrap(err) 95 | } 96 | 97 | rm, err := exists(path.Join(repoPath, ".git", "rebase-merge")) 98 | if err != nil { 99 | return false, tracerr.Wrap(err) 100 | } 101 | 102 | return ra || rm, nil 103 | } 104 | -------------------------------------------------------------------------------- /common/rebase_test.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "testing" 5 | 6 | git "gopkg.in/src-d/go-git.v4" 7 | "gopkg.in/src-d/go-git.v4/plumbing" 8 | "gotest.tools/v3/assert" 9 | ) 10 | 11 | // No new commits on remote or local 12 | func Test_RebaseNothing(t *testing.T) { 13 | repoConfig := PrepareMultiFixtures(t, "rebase_nothing", []string{"rebase_parent"}) 14 | 15 | err := rebase(repoConfig) 16 | assert.NilError(t, err) 17 | 18 | r, err := git.PlainOpen(repoConfig.RepoPath) 19 | assert.NilError(t, err) 20 | 21 | head, err := r.Head() 22 | assert.NilError(t, err) 23 | 24 | assert.Equal(t, head.Hash(), plumbing.NewHash("28cc969d97ddb7640f5e1428bbc8f2947d1ffd57")) 25 | } 26 | 27 | // New commits on local 28 | func Test_RebaseLocalCommits(t *testing.T) { 29 | repoConfig := PrepareMultiFixtures(t, "rebase_local_commits", []string{"rebase_parent"}) 30 | 31 | err := rebase(repoConfig) 32 | assert.NilError(t, err) 33 | 34 | r, err := git.PlainOpen(repoConfig.RepoPath) 35 | assert.NilError(t, err) 36 | 37 | head, err := r.Head() 38 | assert.NilError(t, err) 39 | 40 | assert.Equal(t, head.Hash(), plumbing.NewHash("7fc438e0c9cc4f58178a1efe8521e52f0f8ee688")) 41 | } 42 | 43 | // New commits on remote 44 | func Test_RebaseRemoteCommits(t *testing.T) { 45 | repoConfig := PrepareMultiFixtures(t, "rebase_remote_commits", []string{"rebase_parent"}) 46 | 47 | err := rebase(repoConfig) 48 | assert.NilError(t, err) 49 | 50 | r, err := git.PlainOpen(repoConfig.RepoPath) 51 | assert.NilError(t, err) 52 | 53 | head, err := r.Head() 54 | assert.NilError(t, err) 55 | 56 | assert.Equal(t, head.Hash(), plumbing.NewHash("ccda8f2e691aa416791a10afc74ccdbd1cb419fe")) 57 | } 58 | 59 | // New commits on both, no conflict 60 | func Test_RebaseBothCommitsNoConflict(t *testing.T) { 61 | repoConfig := PrepareMultiFixtures(t, "rebase_both_commits", []string{"rebase_parent"}) 62 | 63 | err := rebase(repoConfig) 64 | assert.NilError(t, err) 65 | 66 | r, err := git.PlainOpen(repoConfig.RepoPath) 67 | assert.NilError(t, err) 68 | 69 | head, err := r.Head() 70 | assert.NilError(t, err) 71 | 72 | assert.Check(t, head.Hash() != plumbing.NewHash("ccda8f2e691aa416791a10afc74ccdbd1cb419fe")) 73 | assert.Check(t, head.Hash() != plumbing.NewHash("5779561afa9d074ae8d20974861c54757429aca9")) 74 | assert.Check(t, head.Hash() != plumbing.NewHash("7fc438e0c9cc4f58178a1efe8521e52f0f8ee688")) 75 | } 76 | 77 | // New commits on both, some kind of conflict 78 | func Test_RebaseBothCommitsConflict(t *testing.T) { 79 | repoConfig := PrepareMultiFixtures(t, "rebase_both_commits_conflict", []string{"rebase_parent"}) 80 | 81 | r, err := git.PlainOpen(repoConfig.RepoPath) 82 | assert.NilError(t, err) 83 | 84 | origHead, err := r.Head() 85 | assert.NilError(t, err) 86 | 87 | err = rebase(repoConfig) 88 | assert.Equal(t, err, errRebaseFailed) 89 | 90 | newHead, err := r.Head() 91 | assert.NilError(t, err) 92 | 93 | assert.Check(t, newHead.Hash() == origHead.Hash()) 94 | } 95 | -------------------------------------------------------------------------------- /common/service.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | "runtime" 8 | "strings" 9 | 10 | "github.com/kardianos/service" 11 | "github.com/ztrue/tracerr" 12 | ) 13 | 14 | type Service struct { 15 | Service service.Service 16 | } 17 | 18 | type emptyDaemon struct{} 19 | 20 | func (d emptyDaemon) Start(s service.Service) error { 21 | return nil 22 | } 23 | 24 | func (d emptyDaemon) Stop(s service.Service) error { 25 | return nil 26 | } 27 | 28 | func NewServiceWithDaemon(daemon service.Interface) (Service, error) { 29 | options := make(service.KeyValue) 30 | options["Restart"] = "on-success" 31 | options["UserService"] = true 32 | options["RunAtLoad"] = true 33 | 34 | ex, err := os.Executable() 35 | if err != nil { 36 | return Service{}, tracerr.Wrap(err) 37 | } 38 | exDirPath := filepath.Dir(ex) 39 | executablePath := filepath.Join(exDirPath, "git-auto-sync-daemon") 40 | 41 | deps := []string{} 42 | if runtime.GOOS == "linux" { 43 | deps = []string{"After=network-online.target syslog.target"} 44 | } 45 | 46 | svcConfig := &service.Config{ 47 | Name: "git-auto-sync-daemon", 48 | DisplayName: "Git Auto Sync Daemon", 49 | Description: "Background Process for Auto Syncing Git Repos", 50 | 51 | Executable: executablePath, 52 | Dependencies: deps, 53 | Option: options, 54 | } 55 | 56 | s, err := service.New(daemon, svcConfig) 57 | if err != nil { 58 | return Service{}, tracerr.Wrap(err) 59 | } 60 | 61 | return Service{Service: s}, nil 62 | } 63 | 64 | func NewService() (Service, error) { 65 | return NewServiceWithDaemon(emptyDaemon{}) 66 | } 67 | 68 | func (srv Service) Enable() error { 69 | s := srv.Service 70 | 71 | status, err := s.Status() 72 | if err != nil { 73 | if !strings.Contains(err.Error(), "the service is not installed") { 74 | return tracerr.Wrap(err) 75 | } 76 | } 77 | 78 | stopped := false 79 | if status == service.StatusRunning { 80 | err := s.Stop() 81 | if err != nil { 82 | return tracerr.Wrap(err) 83 | } 84 | stopped = true 85 | } 86 | 87 | err = s.Install() 88 | if err != nil { 89 | if strings.Contains(err.Error(), "Init already exists") { 90 | _ = s.Uninstall() 91 | _ = s.Install() 92 | } else { 93 | return tracerr.Wrap(err) 94 | } 95 | } else { 96 | fmt.Println("Installing git-auto-sync as a daemon") 97 | } 98 | 99 | if stopped { 100 | fmt.Println("Restarting git-auto-sync-daemon") 101 | } else { 102 | fmt.Println("Starting git-auto-sync-daemon") 103 | } 104 | 105 | err = s.Start() 106 | if err != nil { 107 | return tracerr.Wrap(err) 108 | } 109 | 110 | return nil 111 | } 112 | 113 | func (srv Service) Disable() error { 114 | fmt.Println("Stopping git-auto-sync-daemon") 115 | err := srv.Service.Stop() 116 | if err != nil { 117 | return tracerr.Wrap(err) 118 | } 119 | 120 | fmt.Println("Uninstalling git-auto-sync as a daemon") 121 | err = srv.Service.Uninstall() 122 | if err != nil { 123 | return tracerr.Wrap(err) 124 | } 125 | 126 | return nil 127 | } 128 | 129 | func (srv Service) Status() error { 130 | status, err := srv.Service.Status() 131 | if err != nil { 132 | return tracerr.Wrap(err) 133 | } 134 | 135 | switch status { 136 | case service.StatusRunning: 137 | fmt.Println("git-auto-sync-daemon is Running!") 138 | case service.StatusStopped: 139 | fmt.Println("git-auto-sync-daemon is NOT Running!") 140 | case service.StatusUnknown: 141 | default: 142 | fmt.Println("git-auto-sync-daemon status is Unknown. How mysterious!") 143 | } 144 | 145 | return nil 146 | } 147 | -------------------------------------------------------------------------------- /common/testdata/ignore/.gitignore: -------------------------------------------------------------------------------- 1 | *.txt 2 | -------------------------------------------------------------------------------- /common/testdata/ignore/.gitted/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /common/testdata/ignore/.gitted/branches/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/ignore/.gitted/branches/.gitignore -------------------------------------------------------------------------------- /common/testdata/ignore/.gitted/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = false 5 | logallrefupdates = true 6 | -------------------------------------------------------------------------------- /common/testdata/ignore/.gitted/description: -------------------------------------------------------------------------------- 1 | Unnamed repository; edit this file 'description' to name the repository. 2 | -------------------------------------------------------------------------------- /common/testdata/ignore/.gitted/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/ignore/.gitted/index -------------------------------------------------------------------------------- /common/testdata/ignore/.gitted/info/refs: -------------------------------------------------------------------------------- 1 | 94f6ec1962b3b8d1dc2358e1be9f684fd41c2264 refs/heads/master 2 | -------------------------------------------------------------------------------- /common/testdata/ignore/.gitted/objects/pack/pack-6084461925de24b5672557d115a4eff8b2d92326.idx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/ignore/.gitted/objects/pack/pack-6084461925de24b5672557d115a4eff8b2d92326.idx -------------------------------------------------------------------------------- /common/testdata/ignore/.gitted/objects/pack/pack-6084461925de24b5672557d115a4eff8b2d92326.pack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/ignore/.gitted/objects/pack/pack-6084461925de24b5672557d115a4eff8b2d92326.pack -------------------------------------------------------------------------------- /common/testdata/ignore/.gitted/packed-refs: -------------------------------------------------------------------------------- 1 | # pack-refs with: peeled fully-peeled sorted 2 | 94f6ec1962b3b8d1dc2358e1be9f684fd41c2264 refs/heads/master 3 | -------------------------------------------------------------------------------- /common/testdata/ignore/.gitted/refs/heads/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/ignore/.gitted/refs/heads/.gitignore -------------------------------------------------------------------------------- /common/testdata/ignore/.gitted/refs/tags/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/ignore/.gitted/refs/tags/.gitignore -------------------------------------------------------------------------------- /common/testdata/ignore/1.md: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /common/testdata/multiple_file_change/.gitted/COMMIT_EDITMSG: -------------------------------------------------------------------------------- 1 | Add another file in a subdir 2 | # Please enter the commit message for your changes. Lines starting 3 | # with '#' will be ignored, and an empty message aborts the commit. 4 | # 5 | # On branch master 6 | # Changes to be committed: 7 | # new file: dirA/2.md 8 | # 9 | # Changes not staged for commit: 10 | # modified: 1.md 11 | # 12 | # Untracked files: 13 | # dirB/ 14 | # 15 | # ------------------------ >8 ------------------------ 16 | # Do not modify or remove the line above. 17 | # Everything below it will be ignored. 18 | diff --git a/dirA/2.md b/dirA/2.md 19 | new file mode 100644 20 | index 0000000..0cfbf08 21 | --- /dev/null 22 | +++ b/dirA/2.md 23 | @@ -0,0 +1 @@ 24 | +2 25 | -------------------------------------------------------------------------------- /common/testdata/multiple_file_change/.gitted/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /common/testdata/multiple_file_change/.gitted/branches/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/multiple_file_change/.gitted/branches/.gitignore -------------------------------------------------------------------------------- /common/testdata/multiple_file_change/.gitted/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = false 5 | logallrefupdates = true 6 | -------------------------------------------------------------------------------- /common/testdata/multiple_file_change/.gitted/description: -------------------------------------------------------------------------------- 1 | Unnamed repository; edit this file 'description' to name the repository. 2 | -------------------------------------------------------------------------------- /common/testdata/multiple_file_change/.gitted/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/multiple_file_change/.gitted/index -------------------------------------------------------------------------------- /common/testdata/multiple_file_change/.gitted/info/refs: -------------------------------------------------------------------------------- 1 | 7058b6b292ee3d1382670334b5f29570a1117ef1 refs/heads/master 2 | -------------------------------------------------------------------------------- /common/testdata/multiple_file_change/.gitted/logs/HEAD: -------------------------------------------------------------------------------- 1 | 28cc969d97ddb7640f5e1428bbc8f2947d1ffd57 7058b6b292ee3d1382670334b5f29570a1117ef1 Vishesh Handa 1651236187 +0200 commit: Add another file in a subdir 2 | -------------------------------------------------------------------------------- /common/testdata/multiple_file_change/.gitted/logs/refs/heads/master: -------------------------------------------------------------------------------- 1 | 28cc969d97ddb7640f5e1428bbc8f2947d1ffd57 7058b6b292ee3d1382670334b5f29570a1117ef1 Vishesh Handa 1651236187 +0200 commit: Add another file in a subdir 2 | -------------------------------------------------------------------------------- /common/testdata/multiple_file_change/.gitted/objects/info/commit-graph: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/multiple_file_change/.gitted/objects/info/commit-graph -------------------------------------------------------------------------------- /common/testdata/multiple_file_change/.gitted/objects/info/packs: -------------------------------------------------------------------------------- 1 | P pack-8bd23478afc278bb9d444418db77fa24b756f8b8.pack 2 | 3 | -------------------------------------------------------------------------------- /common/testdata/multiple_file_change/.gitted/objects/pack/pack-8bd23478afc278bb9d444418db77fa24b756f8b8.idx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/multiple_file_change/.gitted/objects/pack/pack-8bd23478afc278bb9d444418db77fa24b756f8b8.idx -------------------------------------------------------------------------------- /common/testdata/multiple_file_change/.gitted/objects/pack/pack-8bd23478afc278bb9d444418db77fa24b756f8b8.pack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/multiple_file_change/.gitted/objects/pack/pack-8bd23478afc278bb9d444418db77fa24b756f8b8.pack -------------------------------------------------------------------------------- /common/testdata/multiple_file_change/.gitted/packed-refs: -------------------------------------------------------------------------------- 1 | # pack-refs with: peeled fully-peeled sorted 2 | 7058b6b292ee3d1382670334b5f29570a1117ef1 refs/heads/master 3 | -------------------------------------------------------------------------------- /common/testdata/multiple_file_change/.gitted/refs/heads/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/multiple_file_change/.gitted/refs/heads/.gitignore -------------------------------------------------------------------------------- /common/testdata/multiple_file_change/.gitted/refs/tags/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/multiple_file_change/.gitted/refs/tags/.gitignore -------------------------------------------------------------------------------- /common/testdata/multiple_file_change/1.md: -------------------------------------------------------------------------------- 1 | 1 2 | Foo 3 | -------------------------------------------------------------------------------- /common/testdata/multiple_file_change/dirB/3.md: -------------------------------------------------------------------------------- 1 | 3 2 | 4 3 | -------------------------------------------------------------------------------- /common/testdata/new_file/.gitted/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /common/testdata/new_file/.gitted/branches/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/new_file/.gitted/branches/.gitignore -------------------------------------------------------------------------------- /common/testdata/new_file/.gitted/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = false 5 | logallrefupdates = true 6 | -------------------------------------------------------------------------------- /common/testdata/new_file/.gitted/description: -------------------------------------------------------------------------------- 1 | Unnamed repository; edit this file 'description' to name the repository. 2 | -------------------------------------------------------------------------------- /common/testdata/new_file/.gitted/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/new_file/.gitted/index -------------------------------------------------------------------------------- /common/testdata/new_file/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.idx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/new_file/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.idx -------------------------------------------------------------------------------- /common/testdata/new_file/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.pack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/new_file/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.pack -------------------------------------------------------------------------------- /common/testdata/new_file/.gitted/packed-refs: -------------------------------------------------------------------------------- 1 | # pack-refs with: peeled fully-peeled sorted 2 | 28cc969d97ddb7640f5e1428bbc8f2947d1ffd57 refs/heads/master 3 | -------------------------------------------------------------------------------- /common/testdata/new_file/.gitted/refs/heads/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/new_file/.gitted/refs/heads/.gitignore -------------------------------------------------------------------------------- /common/testdata/new_file/.gitted/refs/tags/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/new_file/.gitted/refs/tags/.gitignore -------------------------------------------------------------------------------- /common/testdata/new_file/1.md: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /common/testdata/new_file/2.md: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /common/testdata/no_changes/.gitted/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /common/testdata/no_changes/.gitted/branches/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/no_changes/.gitted/branches/.gitignore -------------------------------------------------------------------------------- /common/testdata/no_changes/.gitted/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = false 5 | logallrefupdates = true 6 | -------------------------------------------------------------------------------- /common/testdata/no_changes/.gitted/description: -------------------------------------------------------------------------------- 1 | Unnamed repository; edit this file 'description' to name the repository. 2 | -------------------------------------------------------------------------------- /common/testdata/no_changes/.gitted/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/no_changes/.gitted/index -------------------------------------------------------------------------------- /common/testdata/no_changes/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.idx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/no_changes/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.idx -------------------------------------------------------------------------------- /common/testdata/no_changes/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.pack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/no_changes/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.pack -------------------------------------------------------------------------------- /common/testdata/no_changes/.gitted/packed-refs: -------------------------------------------------------------------------------- 1 | # pack-refs with: peeled fully-peeled sorted 2 | 28cc969d97ddb7640f5e1428bbc8f2947d1ffd57 refs/heads/master 3 | -------------------------------------------------------------------------------- /common/testdata/no_changes/.gitted/refs/heads/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/no_changes/.gitted/refs/heads/.gitignore -------------------------------------------------------------------------------- /common/testdata/no_changes/.gitted/refs/tags/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/no_changes/.gitted/refs/tags/.gitignore -------------------------------------------------------------------------------- /common/testdata/no_changes/1.md: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /common/testdata/one_file_change/.gitted/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /common/testdata/one_file_change/.gitted/branches/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/one_file_change/.gitted/branches/.gitignore -------------------------------------------------------------------------------- /common/testdata/one_file_change/.gitted/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = false 5 | logallrefupdates = true 6 | -------------------------------------------------------------------------------- /common/testdata/one_file_change/.gitted/description: -------------------------------------------------------------------------------- 1 | Unnamed repository; edit this file 'description' to name the repository. 2 | -------------------------------------------------------------------------------- /common/testdata/one_file_change/.gitted/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/one_file_change/.gitted/index -------------------------------------------------------------------------------- /common/testdata/one_file_change/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.idx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/one_file_change/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.idx -------------------------------------------------------------------------------- /common/testdata/one_file_change/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.pack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/one_file_change/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.pack -------------------------------------------------------------------------------- /common/testdata/one_file_change/.gitted/packed-refs: -------------------------------------------------------------------------------- 1 | # pack-refs with: peeled fully-peeled sorted 2 | 28cc969d97ddb7640f5e1428bbc8f2947d1ffd57 refs/heads/master 3 | -------------------------------------------------------------------------------- /common/testdata/one_file_change/.gitted/refs/heads/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/one_file_change/.gitted/refs/heads/.gitignore -------------------------------------------------------------------------------- /common/testdata/one_file_change/.gitted/refs/tags/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/one_file_change/.gitted/refs/tags/.gitignore -------------------------------------------------------------------------------- /common/testdata/one_file_change/1.md: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits/.gitted/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits/.gitted/branches/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_both_commits/.gitted/branches/.gitignore -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits/.gitted/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = false 5 | logallrefupdates = true 6 | [remote "origin"] 7 | url = file://$TESTDATA$/rebase_parent 8 | fetch = +refs/heads/*:refs/remotes/origin/* 9 | [branch "master"] 10 | remote = origin 11 | merge = refs/heads/master 12 | -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits/.gitted/description: -------------------------------------------------------------------------------- 1 | Unnamed repository; edit this file 'description' to name the repository. 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits/.gitted/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_both_commits/.gitted/index -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits/.gitted/objects/57/79561afa9d074ae8d20974861c54757429aca9: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_both_commits/.gitted/objects/57/79561afa9d074ae8d20974861c54757429aca9 -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits/.gitted/objects/5b/2421e1ef4d7f32306709aab06b1a6c02294b30: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_both_commits/.gitted/objects/5b/2421e1ef4d7f32306709aab06b1a6c02294b30 -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits/.gitted/objects/b8/626c4cff2849624fb67f87cd0ad72b163671ad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_both_commits/.gitted/objects/b8/626c4cff2849624fb67f87cd0ad72b163671ad -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits/.gitted/objects/bb/42c22f4d5ce6083275b82e129a4b7868913015: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_both_commits/.gitted/objects/bb/42c22f4d5ce6083275b82e129a4b7868913015 -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits/.gitted/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_both_commits/.gitted/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits/.gitted/objects/pack/pack-5acce72f5df296705a9b2e13dc0581d7f0b26f96.idx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_both_commits/.gitted/objects/pack/pack-5acce72f5df296705a9b2e13dc0581d7f0b26f96.idx -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits/.gitted/objects/pack/pack-5acce72f5df296705a9b2e13dc0581d7f0b26f96.pack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_both_commits/.gitted/objects/pack/pack-5acce72f5df296705a9b2e13dc0581d7f0b26f96.pack -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits/.gitted/packed-refs: -------------------------------------------------------------------------------- 1 | # pack-refs with: peeled fully-peeled sorted 2 | 7fc438e0c9cc4f58178a1efe8521e52f0f8ee688 refs/heads/master 3 | ccda8f2e691aa416791a10afc74ccdbd1cb419fe refs/remotes/origin/master 4 | -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits/.gitted/refs/heads/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_both_commits/.gitted/refs/heads/.gitignore -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits/.gitted/refs/tags/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_both_commits/.gitted/refs/tags/.gitignore -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits/1.md: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits/2.md: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits_conflict/.gitted/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits_conflict/.gitted/branches/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_both_commits_conflict/.gitted/branches/.gitignore -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits_conflict/.gitted/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = false 5 | logallrefupdates = true 6 | [remote "origin"] 7 | url = file://$TESTDATA$/rebase_parent 8 | fetch = +refs/heads/*:refs/remotes/origin/* 9 | [branch "master"] 10 | remote = origin 11 | merge = refs/heads/master 12 | -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits_conflict/.gitted/description: -------------------------------------------------------------------------------- 1 | Unnamed repository; edit this file 'description' to name the repository. 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits_conflict/.gitted/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_both_commits_conflict/.gitted/index -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits_conflict/.gitted/info/refs: -------------------------------------------------------------------------------- 1 | 5779561afa9d074ae8d20974861c54757429aca9 refs/heads/master 2 | ccda8f2e691aa416791a10afc74ccdbd1cb419fe refs/remotes/origin/master 3 | -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits_conflict/.gitted/objects/5b/2421e1ef4d7f32306709aab06b1a6c02294b30: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_both_commits_conflict/.gitted/objects/5b/2421e1ef4d7f32306709aab06b1a6c02294b30 -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits_conflict/.gitted/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_both_commits_conflict/.gitted/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits_conflict/.gitted/objects/info/commit-graph: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_both_commits_conflict/.gitted/objects/info/commit-graph -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits_conflict/.gitted/objects/info/packs: -------------------------------------------------------------------------------- 1 | P pack-fd52ab0ce127a1919ff8c45b06c172528a4e8fb7.pack 2 | 3 | -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits_conflict/.gitted/objects/pack/pack-fd52ab0ce127a1919ff8c45b06c172528a4e8fb7.idx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_both_commits_conflict/.gitted/objects/pack/pack-fd52ab0ce127a1919ff8c45b06c172528a4e8fb7.idx -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits_conflict/.gitted/objects/pack/pack-fd52ab0ce127a1919ff8c45b06c172528a4e8fb7.pack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_both_commits_conflict/.gitted/objects/pack/pack-fd52ab0ce127a1919ff8c45b06c172528a4e8fb7.pack -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits_conflict/.gitted/packed-refs: -------------------------------------------------------------------------------- 1 | # pack-refs with: peeled fully-peeled sorted 2 | 5779561afa9d074ae8d20974861c54757429aca9 refs/heads/master 3 | ccda8f2e691aa416791a10afc74ccdbd1cb419fe refs/remotes/origin/master 4 | -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits_conflict/.gitted/refs/heads/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_both_commits_conflict/.gitted/refs/heads/.gitignore -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits_conflict/.gitted/refs/tags/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_both_commits_conflict/.gitted/refs/tags/.gitignore -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits_conflict/1.md: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits_conflict/2.md: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_both_commits_conflict/3.md: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_local_commits/.gitted/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_local_commits/.gitted/branches/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_local_commits/.gitted/branches/.gitignore -------------------------------------------------------------------------------- /common/testdata/rebase_local_commits/.gitted/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = false 5 | logallrefupdates = true 6 | [remote "origin"] 7 | url = file://$TESTDATA$/rebase_parent 8 | fetch = +refs/heads/*:refs/remotes/origin/* 9 | [branch "master"] 10 | remote = origin 11 | merge = refs/heads/master 12 | -------------------------------------------------------------------------------- /common/testdata/rebase_local_commits/.gitted/description: -------------------------------------------------------------------------------- 1 | Unnamed repository; edit this file 'description' to name the repository. 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_local_commits/.gitted/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_local_commits/.gitted/index -------------------------------------------------------------------------------- /common/testdata/rebase_local_commits/.gitted/info/refs: -------------------------------------------------------------------------------- 1 | 7fc438e0c9cc4f58178a1efe8521e52f0f8ee688 refs/heads/master 2 | 28cc969d97ddb7640f5e1428bbc8f2947d1ffd57 refs/remotes/origin/master 3 | -------------------------------------------------------------------------------- /common/testdata/rebase_local_commits/.gitted/objects/pack/pack-6ed5aab84549686dd1639003c49f7f7aede63325.idx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_local_commits/.gitted/objects/pack/pack-6ed5aab84549686dd1639003c49f7f7aede63325.idx -------------------------------------------------------------------------------- /common/testdata/rebase_local_commits/.gitted/objects/pack/pack-6ed5aab84549686dd1639003c49f7f7aede63325.pack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_local_commits/.gitted/objects/pack/pack-6ed5aab84549686dd1639003c49f7f7aede63325.pack -------------------------------------------------------------------------------- /common/testdata/rebase_local_commits/.gitted/packed-refs: -------------------------------------------------------------------------------- 1 | # pack-refs with: peeled fully-peeled sorted 2 | 7fc438e0c9cc4f58178a1efe8521e52f0f8ee688 refs/heads/master 3 | 28cc969d97ddb7640f5e1428bbc8f2947d1ffd57 refs/remotes/origin/master 4 | -------------------------------------------------------------------------------- /common/testdata/rebase_local_commits/.gitted/refs/heads/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_local_commits/.gitted/refs/heads/.gitignore -------------------------------------------------------------------------------- /common/testdata/rebase_local_commits/.gitted/refs/tags/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_local_commits/.gitted/refs/tags/.gitignore -------------------------------------------------------------------------------- /common/testdata/rebase_local_commits/1.md: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_local_commits/2.md: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_nothing/.gitted/FETCH_HEAD: -------------------------------------------------------------------------------- 1 | 28cc969d97ddb7640f5e1428bbc8f2947d1ffd57 not-for-merge branch 'master' of file:///Users/vishesh/src/gitjournal/git-auto-sync/testdata/rebase_parent 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_nothing/.gitted/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_nothing/.gitted/branches/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_nothing/.gitted/branches/.gitignore -------------------------------------------------------------------------------- /common/testdata/rebase_nothing/.gitted/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = false 5 | logallrefupdates = true 6 | [remote "origin"] 7 | url = file://$TESTDATA$/rebase_parent 8 | fetch = +refs/heads/*:refs/remotes/origin/* 9 | [branch "master"] 10 | remote = origin 11 | merge = refs/heads/master 12 | -------------------------------------------------------------------------------- /common/testdata/rebase_nothing/.gitted/description: -------------------------------------------------------------------------------- 1 | Unnamed repository; edit this file 'description' to name the repository. 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_nothing/.gitted/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_nothing/.gitted/index -------------------------------------------------------------------------------- /common/testdata/rebase_nothing/.gitted/logs/refs/remotes/origin/master: -------------------------------------------------------------------------------- 1 | 0000000000000000000000000000000000000000 28cc969d97ddb7640f5e1428bbc8f2947d1ffd57 Vishesh Handa 1651442600 +0200 fetch origin: storing head 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_nothing/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.idx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_nothing/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.idx -------------------------------------------------------------------------------- /common/testdata/rebase_nothing/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.pack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_nothing/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.pack -------------------------------------------------------------------------------- /common/testdata/rebase_nothing/.gitted/packed-refs: -------------------------------------------------------------------------------- 1 | # pack-refs with: peeled fully-peeled sorted 2 | 28cc969d97ddb7640f5e1428bbc8f2947d1ffd57 refs/heads/master 3 | -------------------------------------------------------------------------------- /common/testdata/rebase_nothing/.gitted/refs/heads/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_nothing/.gitted/refs/heads/.gitignore -------------------------------------------------------------------------------- /common/testdata/rebase_nothing/.gitted/refs/remotes/origin/master: -------------------------------------------------------------------------------- 1 | 28cc969d97ddb7640f5e1428bbc8f2947d1ffd57 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_nothing/.gitted/refs/tags/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_nothing/.gitted/refs/tags/.gitignore -------------------------------------------------------------------------------- /common/testdata/rebase_nothing/1.md: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_parent/.gitted/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_parent/.gitted/branches/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_parent/.gitted/branches/.gitignore -------------------------------------------------------------------------------- /common/testdata/rebase_parent/.gitted/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = false 5 | logallrefupdates = true 6 | -------------------------------------------------------------------------------- /common/testdata/rebase_parent/.gitted/description: -------------------------------------------------------------------------------- 1 | Unnamed repository; edit this file 'description' to name the repository. 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_parent/.gitted/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_parent/.gitted/index -------------------------------------------------------------------------------- /common/testdata/rebase_parent/.gitted/objects/pack/pack-0e97b284249125dd68802efc8e497badec0ab786.idx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_parent/.gitted/objects/pack/pack-0e97b284249125dd68802efc8e497badec0ab786.idx -------------------------------------------------------------------------------- /common/testdata/rebase_parent/.gitted/objects/pack/pack-0e97b284249125dd68802efc8e497badec0ab786.pack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_parent/.gitted/objects/pack/pack-0e97b284249125dd68802efc8e497badec0ab786.pack -------------------------------------------------------------------------------- /common/testdata/rebase_parent/.gitted/packed-refs: -------------------------------------------------------------------------------- 1 | # pack-refs with: peeled fully-peeled sorted 2 | ccda8f2e691aa416791a10afc74ccdbd1cb419fe refs/heads/master 3 | -------------------------------------------------------------------------------- /common/testdata/rebase_parent/.gitted/refs/heads/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_parent/.gitted/refs/heads/.gitignore -------------------------------------------------------------------------------- /common/testdata/rebase_parent/.gitted/refs/tags/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_parent/.gitted/refs/tags/.gitignore -------------------------------------------------------------------------------- /common/testdata/rebase_parent/1.md: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_parent/3.md: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_remote_commits/.gitted/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_remote_commits/.gitted/branches/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_remote_commits/.gitted/branches/.gitignore -------------------------------------------------------------------------------- /common/testdata/rebase_remote_commits/.gitted/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = false 5 | logallrefupdates = true 6 | [remote "origin"] 7 | url = file://$TESTDATA$/rebase_parent 8 | fetch = +refs/heads/*:refs/remotes/origin/* 9 | [branch "master"] 10 | remote = origin 11 | merge = refs/heads/master 12 | -------------------------------------------------------------------------------- /common/testdata/rebase_remote_commits/.gitted/description: -------------------------------------------------------------------------------- 1 | Unnamed repository; edit this file 'description' to name the repository. 2 | -------------------------------------------------------------------------------- /common/testdata/rebase_remote_commits/.gitted/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_remote_commits/.gitted/index -------------------------------------------------------------------------------- /common/testdata/rebase_remote_commits/.gitted/info/refs: -------------------------------------------------------------------------------- 1 | 28cc969d97ddb7640f5e1428bbc8f2947d1ffd57 refs/heads/master 2 | ccda8f2e691aa416791a10afc74ccdbd1cb419fe refs/remotes/origin/master 3 | -------------------------------------------------------------------------------- /common/testdata/rebase_remote_commits/.gitted/objects/pack/pack-6c99d95700f1ca8eaa8f19957b0c70a80a1d0b72.idx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_remote_commits/.gitted/objects/pack/pack-6c99d95700f1ca8eaa8f19957b0c70a80a1d0b72.idx -------------------------------------------------------------------------------- /common/testdata/rebase_remote_commits/.gitted/objects/pack/pack-6c99d95700f1ca8eaa8f19957b0c70a80a1d0b72.pack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_remote_commits/.gitted/objects/pack/pack-6c99d95700f1ca8eaa8f19957b0c70a80a1d0b72.pack -------------------------------------------------------------------------------- /common/testdata/rebase_remote_commits/.gitted/packed-refs: -------------------------------------------------------------------------------- 1 | # pack-refs with: peeled fully-peeled sorted 2 | 28cc969d97ddb7640f5e1428bbc8f2947d1ffd57 refs/heads/master 3 | ccda8f2e691aa416791a10afc74ccdbd1cb419fe refs/remotes/origin/master 4 | -------------------------------------------------------------------------------- /common/testdata/rebase_remote_commits/.gitted/refs/heads/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_remote_commits/.gitted/refs/heads/.gitignore -------------------------------------------------------------------------------- /common/testdata/rebase_remote_commits/.gitted/refs/tags/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/rebase_remote_commits/.gitted/refs/tags/.gitignore -------------------------------------------------------------------------------- /common/testdata/rebase_remote_commits/1.md: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /common/testdata/simple_fetch/.gitted/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /common/testdata/simple_fetch/.gitted/branches/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/simple_fetch/.gitted/branches/.gitignore -------------------------------------------------------------------------------- /common/testdata/simple_fetch/.gitted/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = false 5 | logallrefupdates = true 6 | [remote "origin1"] 7 | url = file://$TESTDATA$/multiple_file_change/.git 8 | fetch = +refs/heads/*:refs/remotes/origin1/* 9 | -------------------------------------------------------------------------------- /common/testdata/simple_fetch/.gitted/description: -------------------------------------------------------------------------------- 1 | Unnamed repository; edit this file 'description' to name the repository. 2 | -------------------------------------------------------------------------------- /common/testdata/simple_fetch/.gitted/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/simple_fetch/.gitted/index -------------------------------------------------------------------------------- /common/testdata/simple_fetch/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.idx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/simple_fetch/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.idx -------------------------------------------------------------------------------- /common/testdata/simple_fetch/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.pack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/simple_fetch/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.pack -------------------------------------------------------------------------------- /common/testdata/simple_fetch/.gitted/packed-refs: -------------------------------------------------------------------------------- 1 | # pack-refs with: peeled fully-peeled sorted 2 | 28cc969d97ddb7640f5e1428bbc8f2947d1ffd57 refs/heads/master 3 | -------------------------------------------------------------------------------- /common/testdata/simple_fetch/.gitted/refs/heads/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/simple_fetch/.gitted/refs/heads/.gitignore -------------------------------------------------------------------------------- /common/testdata/simple_fetch/.gitted/refs/tags/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/simple_fetch/.gitted/refs/tags/.gitignore -------------------------------------------------------------------------------- /common/testdata/simple_fetch/1.md: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /common/testdata/vim_swap_file/.1.md.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/vim_swap_file/.1.md.swp -------------------------------------------------------------------------------- /common/testdata/vim_swap_file/.gitted/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /common/testdata/vim_swap_file/.gitted/branches/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/vim_swap_file/.gitted/branches/.gitignore -------------------------------------------------------------------------------- /common/testdata/vim_swap_file/.gitted/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = false 5 | logallrefupdates = true 6 | -------------------------------------------------------------------------------- /common/testdata/vim_swap_file/.gitted/description: -------------------------------------------------------------------------------- 1 | Unnamed repository; edit this file 'description' to name the repository. 2 | -------------------------------------------------------------------------------- /common/testdata/vim_swap_file/.gitted/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/vim_swap_file/.gitted/index -------------------------------------------------------------------------------- /common/testdata/vim_swap_file/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.idx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/vim_swap_file/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.idx -------------------------------------------------------------------------------- /common/testdata/vim_swap_file/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.pack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/vim_swap_file/.gitted/objects/pack/pack-64633f8b9e2cb3a97cffd48edac3655d0fe90419.pack -------------------------------------------------------------------------------- /common/testdata/vim_swap_file/.gitted/packed-refs: -------------------------------------------------------------------------------- 1 | # pack-refs with: peeled fully-peeled sorted 2 | 28cc969d97ddb7640f5e1428bbc8f2947d1ffd57 refs/heads/master 3 | -------------------------------------------------------------------------------- /common/testdata/vim_swap_file/.gitted/refs/heads/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/vim_swap_file/.gitted/refs/heads/.gitignore -------------------------------------------------------------------------------- /common/testdata/vim_swap_file/.gitted/refs/tags/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitJournal/git-auto-sync/4c47abae959b5ae687292cd4895216377e06fa9f/common/testdata/vim_swap_file/.gitted/refs/tags/.gitignore -------------------------------------------------------------------------------- /common/testdata/vim_swap_file/1.md: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /common/watch.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "log" 5 | "os" 6 | "path/filepath" 7 | "strconv" 8 | "time" 9 | 10 | "github.com/rjeczalik/notify" 11 | "github.com/ztrue/tracerr" 12 | git "gopkg.in/src-d/go-git.v4" 13 | ) 14 | 15 | // FIXME: Replace the logger with returning an error and retrying after 'x' minutes 16 | 17 | type RepoConfig struct { 18 | RepoPath string 19 | PollInterval time.Duration 20 | FSLag time.Duration 21 | GitExec string 22 | Env []string 23 | } 24 | 25 | type AwakeNotifier interface { 26 | Start(chan bool) error 27 | } 28 | 29 | func NewRepoConfig(repoPath string) (RepoConfig, error) { 30 | repo, err := git.PlainOpen(repoPath) 31 | if err != nil { 32 | return RepoConfig{}, tracerr.Wrap(err) 33 | } 34 | 35 | config, err := repo.Config() 36 | if err != nil { 37 | return RepoConfig{}, tracerr.Wrap(err) 38 | } 39 | 40 | autoSyncSection := config.Raw.Section("auto-sync") 41 | 42 | pollInterval := 10 * time.Minute 43 | if autoSyncSection.Option("syncInterval") != "" { 44 | secondsStr := autoSyncSection.Option("syncInterval") 45 | seconds, err := strconv.Atoi(secondsStr) 46 | if err != nil { 47 | return RepoConfig{}, tracerr.Wrap(err) 48 | } 49 | 50 | pollInterval = time.Duration(seconds) * time.Second 51 | } 52 | 53 | gitExec := "" 54 | if autoSyncSection.Option("exec") != "" { 55 | gitExec = autoSyncSection.Option("exec") 56 | 57 | _, err := os.Stat(gitExec) 58 | if err != nil { 59 | return RepoConfig{}, tracerr.Wrap(err) 60 | } 61 | } 62 | 63 | return RepoConfig{ 64 | RepoPath: repoPath, 65 | PollInterval: pollInterval, 66 | FSLag: 1 * time.Second, 67 | GitExec: gitExec, 68 | }, nil 69 | } 70 | 71 | func WatchForChanges(cfg RepoConfig) error { 72 | repoPath := cfg.RepoPath 73 | var err error 74 | 75 | err = AutoSync(cfg) 76 | if err != nil { 77 | return tracerr.Wrap(err) 78 | } 79 | 80 | notifyFilteredChannel := make(chan bool, 100) 81 | pollTicker := time.NewTicker(cfg.PollInterval) 82 | 83 | // Filtered events 84 | go func() { 85 | notifier, err := NewAwakeNotifier() 86 | if err != nil { 87 | log.Fatalln(err) 88 | } 89 | 90 | err = notifier.Start(notifyFilteredChannel) 91 | if err != nil { 92 | log.Fatalln(err) 93 | } 94 | 95 | for { 96 | select { 97 | case <-notifyFilteredChannel: 98 | // Wait 1 second 99 | timer1 := time.NewTimer(cfg.FSLag) 100 | done := make(chan bool) 101 | go func() { 102 | <-timer1.C 103 | done <- true 104 | }() 105 | 106 | err := AutoSync(cfg) 107 | if err != nil { 108 | log.Fatalln(err) 109 | } 110 | continue 111 | 112 | case <-pollTicker.C: 113 | err := AutoSync(cfg) 114 | if err != nil { 115 | log.Fatalln(err) 116 | } 117 | } 118 | } 119 | }() 120 | 121 | // 122 | // Watch for FS events 123 | // 124 | notifyChannel := make(chan notify.EventInfo, 100) 125 | 126 | err = notify.Watch(filepath.Join(repoPath, "..."), notifyChannel, notify.Write, notify.Rename, notify.Remove, notify.Create) 127 | if err != nil { 128 | return tracerr.Wrap(err) 129 | } 130 | defer notify.Stop(notifyChannel) 131 | 132 | for { 133 | ei := <-notifyChannel 134 | ignore, err := ShouldIgnoreFile(repoPath, ei.Path()) 135 | if err != nil { 136 | return tracerr.Wrap(err) 137 | } 138 | if ignore { 139 | continue 140 | } 141 | 142 | notifyFilteredChannel <- true 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /completions/bash_autocomplete: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | PROG=git-auto-sync 4 | 5 | _cli_bash_autocomplete() { 6 | if [[ "${COMP_WORDS[0]}" != "source" ]]; then 7 | local cur opts base 8 | COMPREPLY=() 9 | cur="${COMP_WORDS[COMP_CWORD]}" 10 | if [[ "$cur" == "-"* ]]; then 11 | opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion ) 12 | else 13 | opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) 14 | fi 15 | COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) 16 | return 0 17 | fi 18 | } 19 | 20 | complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete $PROG 21 | unset PROG 22 | -------------------------------------------------------------------------------- /completions/powershell_autocomplete.ps1: -------------------------------------------------------------------------------- 1 | $fn = $($MyInvocation.MyCommand.Name) 2 | $name = $fn -replace "(.*)\.ps1$", '$1' 3 | Register-ArgumentCompleter -Native -CommandName $name -ScriptBlock { 4 | param($commandName, $wordToComplete, $cursorPosition) 5 | $other = "$wordToComplete --generate-bash-completion" 6 | Invoke-Expression $other | ForEach-Object { 7 | [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) 8 | } 9 | } -------------------------------------------------------------------------------- /completions/zsh_autocomplete: -------------------------------------------------------------------------------- 1 | PROG=git-auto-sync 2 | _CLI_ZSH_AUTOCOMPLETE_HACK=1 3 | 4 | #compdef $PROG 5 | 6 | _cli_zsh_autocomplete() { 7 | 8 | local -a opts 9 | local cur 10 | cur=${words[-1]} 11 | if [[ "$cur" == "-"* ]]; then 12 | opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}") 13 | else 14 | opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}") 15 | fi 16 | 17 | if [[ "${opts[1]}" != "" ]]; then 18 | _describe 'values' opts 19 | else 20 | _files 21 | fi 22 | 23 | return 24 | } 25 | 26 | compdef _cli_zsh_autocomplete $PROG 27 | -------------------------------------------------------------------------------- /daemon.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "log" 7 | "os" 8 | "path/filepath" 9 | "strings" 10 | 11 | "github.com/GitJournal/git-auto-sync/common" 12 | cfg "github.com/GitJournal/git-auto-sync/common/config" 13 | cli "github.com/urfave/cli/v2" 14 | "github.com/ztrue/tracerr" 15 | "golang.org/x/exp/slices" 16 | git "gopkg.in/src-d/go-git.v4" 17 | ) 18 | 19 | var errRepoPathInvalid = errors.New("Not a valid git repo") 20 | 21 | func daemonStatus(ctx *cli.Context) error { 22 | s, err := common.NewService() 23 | if err != nil { 24 | return tracerr.Wrap(err) 25 | } 26 | 27 | err = s.Status() 28 | if err != nil { 29 | return tracerr.Wrap(err) 30 | } 31 | 32 | config, err := cfg.Read() 33 | if err != nil { 34 | return tracerr.Wrap(err) 35 | } 36 | 37 | fmt.Println("Monitoring - ") 38 | for _, repoPath := range config.Repos { 39 | fmt.Println(" ", repoPath) 40 | } 41 | 42 | // FIXME: Print out if there are any 'rebasing' issues and we are paused 43 | 44 | return nil 45 | } 46 | 47 | func daemonList(ctx *cli.Context) error { 48 | config, err := cfg.Read() 49 | if err != nil { 50 | return tracerr.Wrap(err) 51 | } 52 | 53 | for _, repoPath := range config.Repos { 54 | fmt.Println(repoPath) 55 | } 56 | return nil 57 | } 58 | 59 | func daemonAdd(ctx *cli.Context) error { 60 | repoPath := ctx.Args().First() 61 | repoPath, err := filepath.Abs(repoPath) 62 | if err != nil { 63 | return tracerr.Wrap(err) 64 | } 65 | 66 | repoPath, err = isValidGitRepo(repoPath) 67 | if err != nil { 68 | return tracerr.Wrap(err) 69 | } 70 | 71 | config, err := cfg.Read() 72 | if err != nil { 73 | return tracerr.Wrap(err) 74 | } 75 | 76 | if slices.Contains(config.Repos, repoPath) { 77 | fmt.Println("The Daemon is already monitoring " + repoPath) 78 | } else { 79 | config.Repos = append(config.Repos, repoPath) 80 | } 81 | 82 | err = cfg.Write(config) 83 | if err != nil { 84 | return tracerr.Wrap(err) 85 | } 86 | 87 | s, err := common.NewService() 88 | if err != nil { 89 | return tracerr.Wrap(err) 90 | } 91 | 92 | err = s.Enable() 93 | if err != nil { 94 | return tracerr.Wrap(err) 95 | } 96 | 97 | return nil 98 | } 99 | 100 | func isValidGitRepo(repoPath string) (string, error) { 101 | info, err := os.Stat(repoPath) 102 | if os.IsNotExist(err) { 103 | return "", tracerr.Errorf("%w - %s", errRepoPathInvalid, repoPath) 104 | } 105 | 106 | if !info.IsDir() { 107 | return "", tracerr.Errorf("%w - %s", errRepoPathInvalid, repoPath) 108 | } 109 | 110 | _, err = git.PlainOpenWithOptions(repoPath, &git.PlainOpenOptions{DetectDotGit: true}) 111 | if err != nil { 112 | return "", tracerr.Errorf("Not a valid git repo - %s\n%w", repoPath, err) 113 | } 114 | 115 | for { 116 | info, err := os.Stat(filepath.Join(repoPath, ".git")) 117 | if err != nil { 118 | if !os.IsNotExist(err) { 119 | return "", tracerr.Errorf("%w - %s", errRepoPathInvalid, repoPath) 120 | } 121 | } 122 | 123 | if os.IsNotExist(err) { 124 | repoPath = filepath.Dir(repoPath) 125 | continue 126 | } 127 | 128 | if !info.IsDir() { 129 | return "", tracerr.Errorf("%w - %s", errRepoPathInvalid, repoPath) 130 | } 131 | break 132 | } 133 | 134 | return repoPath, nil 135 | } 136 | 137 | func daemonRm(ctx *cli.Context) error { 138 | repoPath := ctx.Args().First() 139 | repoPath, err := filepath.Abs(repoPath) 140 | if err != nil { 141 | return tracerr.Wrap(err) 142 | } 143 | 144 | repoPath, err = isValidGitRepo(repoPath) 145 | if err != nil { 146 | return tracerr.Wrap(err) 147 | } 148 | 149 | config, err := cfg.Read() 150 | if err != nil { 151 | return tracerr.Wrap(err) 152 | } 153 | 154 | pos := -1 155 | for i, rp := range config.Repos { 156 | if rp == repoPath { 157 | pos = i 158 | break 159 | } 160 | } 161 | 162 | if pos == -1 { 163 | err = errors.New("Repo Not tracked") 164 | return tracerr.Errorf("%w - %s", err, repoPath) 165 | } 166 | 167 | config.Repos = remove(config.Repos, pos) 168 | err = cfg.Write(config) 169 | if err != nil { 170 | return tracerr.Wrap(err) 171 | } 172 | 173 | if len(config.Repos) == 0 { 174 | s, err := common.NewService() 175 | if err != nil { 176 | return tracerr.Wrap(err) 177 | } 178 | 179 | err = s.Disable() 180 | if err != nil { 181 | return tracerr.Wrap(err) 182 | } 183 | } 184 | 185 | return nil 186 | } 187 | 188 | func daemonEnv(ctx *cli.Context) error { 189 | vars := ctx.Args().Slice() 190 | 191 | for _, v := range vars { 192 | if !strings.Contains(v, "=") { 193 | log.Fatalln("Env variables must be in the format 'key=value'") 194 | } 195 | } 196 | 197 | config, err := cfg.Read() 198 | if err != nil { 199 | return tracerr.Wrap(err) 200 | } 201 | 202 | envMap := toEnvMap(config.Envs) 203 | newMap := toEnvMap(vars) 204 | 205 | for k, v := range newMap { 206 | envMap[k] = v 207 | } 208 | 209 | config.Envs = toEnvStrings(envMap) 210 | err = cfg.Write(config) 211 | if err != nil { 212 | return tracerr.Wrap(err) 213 | } 214 | 215 | fmt.Println(strings.Join(config.Envs, "\n")) 216 | 217 | return nil 218 | } 219 | 220 | func remove(slice []string, s int) []string { 221 | return append(slice[:s], slice[s+1:]...) 222 | } 223 | 224 | func toEnvMap(envs []string) map[string]string { 225 | m := map[string]string{} 226 | for _, e := range envs { 227 | parts := strings.Split(e, "=") 228 | if len(parts) > 1 { 229 | m[parts[0]] = strings.Join(parts[1:], "=") 230 | } else { 231 | m[e] = "" 232 | } 233 | } 234 | 235 | return m 236 | } 237 | 238 | func toEnvStrings(m map[string]string) []string { 239 | vals := []string{} 240 | for k, v := range m { 241 | x := fmt.Sprintf("%s=%s", k, v) 242 | vals = append(vals, x) 243 | } 244 | 245 | return vals 246 | } 247 | -------------------------------------------------------------------------------- /daemon/.gitignore: -------------------------------------------------------------------------------- 1 | daemon 2 | -------------------------------------------------------------------------------- /daemon/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "sync" 7 | 8 | "github.com/GitJournal/git-auto-sync/common" 9 | cfg "github.com/GitJournal/git-auto-sync/common/config" 10 | "github.com/kardianos/service" 11 | ) 12 | 13 | type Daemon struct{} 14 | 15 | func (d *Daemon) Start(s service.Service) error { 16 | go d.run() 17 | return nil 18 | } 19 | 20 | func (d *Daemon) run() { 21 | config, err := cfg.Read() 22 | if err != nil { 23 | panic(err) 24 | } 25 | 26 | var wg sync.WaitGroup 27 | 28 | for _, repoPath := range config.Repos { 29 | wg.Add(1) 30 | 31 | fmt.Println("Monitoring", repoPath) 32 | go watchForChanges(&wg, repoPath) 33 | } 34 | 35 | wg.Wait() 36 | } 37 | 38 | func (d *Daemon) Stop(s service.Service) error { 39 | // Stop should not block. Return with a few seconds. 40 | return nil 41 | } 42 | 43 | func main() { 44 | daemon := Daemon{} 45 | autoSyncService, err := common.NewServiceWithDaemon(&daemon) 46 | if err != nil { 47 | log.Fatal("BuildService", err) 48 | } 49 | 50 | s := autoSyncService.Service 51 | logger, err := s.Logger(nil) 52 | if err != nil { 53 | log.Fatal("BuildLogger", err) 54 | } 55 | 56 | err = s.Run() 57 | if err != nil { 58 | _ = logger.Error("RunService", err) 59 | } 60 | } 61 | 62 | // FIXME: pass some kind of channel which tells this when to close! 63 | func watchForChanges(wg *sync.WaitGroup, repoPath string) { 64 | defer wg.Done() 65 | 66 | cfg, err := common.NewRepoConfig(repoPath) 67 | if err != nil { 68 | log.Println(err) 69 | } 70 | 71 | err = common.WatchForChanges(cfg) 72 | if err != nil { 73 | log.Println(err) 74 | } 75 | } 76 | 77 | // FIXME: Handle operating system signal which tells it to reload the config 78 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/GitJournal/git-auto-sync 2 | 3 | go 1.18 4 | 5 | require ( 6 | github.com/gen2brain/beeep v0.0.0-20220402123239-6a3042f4b71a 7 | github.com/kardianos/service v1.2.1 8 | github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f 9 | github.com/otiai10/copy v1.7.0 10 | github.com/prashantgupta24/mac-sleep-notifier v1.0.1 11 | github.com/rjeczalik/notify v0.9.2 12 | github.com/urfave/cli/v2 v2.5.1 13 | github.com/ztrue/tracerr v0.3.0 14 | golang.org/x/exp v0.0.0-20220428152302-39d4317da171 15 | gopkg.in/src-d/go-git.v4 v4.13.1 16 | gotest.tools/v3 v3.2.0 17 | ) 18 | 19 | require ( 20 | github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect 21 | github.com/emirpasic/gods v1.12.0 // indirect 22 | github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 // indirect 23 | github.com/godbus/dbus/v5 v5.1.0 // indirect 24 | github.com/google/go-cmp v0.5.5 // indirect 25 | github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect 26 | github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd // indirect 27 | github.com/logrusorgru/aurora v0.0.0-20181002194514-a7b3b318ed4e // indirect 28 | github.com/mitchellh/go-homedir v1.1.0 // indirect 29 | github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect 30 | github.com/russross/blackfriday/v2 v2.1.0 // indirect 31 | github.com/sergi/go-diff v1.0.0 // indirect 32 | github.com/src-d/gcfg v1.4.0 // indirect 33 | github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect 34 | github.com/xanzy/ssh-agent v0.2.1 // indirect 35 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect 36 | golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect 37 | golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32 // indirect 38 | gopkg.in/src-d/go-billy.v4 v4.3.2 // indirect 39 | gopkg.in/warnings.v0 v0.1.2 // indirect 40 | ) 41 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs= 2 | github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs= 3 | github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA= 4 | github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= 5 | github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= 6 | github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= 7 | github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU= 8 | github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= 9 | github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= 10 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 11 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 12 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 13 | github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= 14 | github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= 15 | github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= 16 | github.com/gen2brain/beeep v0.0.0-20220402123239-6a3042f4b71a h1:fwNLHrP5Rbg/mGSXCjtPdpbqv2GucVTA/KMi8wEm6mE= 17 | github.com/gen2brain/beeep v0.0.0-20220402123239-6a3042f4b71a/go.mod h1:/WeFVhhxMOGypVKS0w8DUJxUBbHypnWkUVnW7p5c9Pw= 18 | github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= 19 | github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= 20 | github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 h1:qZNfIGkIANxGv/OqtnntR4DfOY2+BgwR60cAcu/i3SE= 21 | github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4/go.mod h1:kW3HQ4UdaAyrUCSSDR4xUzBKW6O2iA4uHhk7AtyYp10= 22 | github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= 23 | github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= 24 | github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 25 | github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= 26 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 27 | github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= 28 | github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= 29 | github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= 30 | github.com/kardianos/service v1.2.1 h1:AYndMsehS+ywIS6RB9KOlcXzteWUzxgMgBymJD7+BYk= 31 | github.com/kardianos/service v1.2.1/go.mod h1:CIMRFEJVL+0DS1a3Nx06NaMn4Dz63Ng6O7dl0qH0zVM= 32 | github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY= 33 | github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= 34 | github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f h1:dKccXx7xA56UNqOcFIbuqFjAWPVtP688j5QMgmo6OHU= 35 | github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f/go.mod h1:4rEELDSfUAlBSyUjPG0JnaNGjf13JySHFeRdD/3dLP0= 36 | github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= 37 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 38 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 39 | github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= 40 | github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= 41 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 42 | github.com/logrusorgru/aurora v0.0.0-20181002194514-a7b3b318ed4e h1:9MlwzLdW7QSDrhDjFlsEYmxpFyIoXmYRon3dt0io31k= 43 | github.com/logrusorgru/aurora v0.0.0-20181002194514-a7b3b318ed4e/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= 44 | github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= 45 | github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= 46 | github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ= 47 | github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= 48 | github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE= 49 | github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U= 50 | github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= 51 | github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= 52 | github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= 53 | github.com/otiai10/mint v1.3.3 h1:7JgpsBaN0uMkyju4tbYHu0mnM55hNKVYLsXmwr15NQI= 54 | github.com/otiai10/mint v1.3.3/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= 55 | github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo= 56 | github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= 57 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 58 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 59 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 60 | github.com/prashantgupta24/mac-sleep-notifier v1.0.1 h1:xd1lPtnn1gxGNjD2tCoVDoOtiQcQ8B9KNFhcWgGqreQ= 61 | github.com/prashantgupta24/mac-sleep-notifier v1.0.1/go.mod h1:bcfTio1xW+rjjZzdF0kbMEs9mcCEmrOBOSK+Jeml7zM= 62 | github.com/rjeczalik/notify v0.9.2 h1:MiTWrPj55mNDHEiIX5YUSKefw/+lCQVoAFmD6oQm5w8= 63 | github.com/rjeczalik/notify v0.9.2/go.mod h1:aErll2f0sUX9PXZnVNyeiObbmTlk5jnMoCa4QEjJeqM= 64 | github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= 65 | github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 66 | github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= 67 | github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= 68 | github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 69 | github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4= 70 | github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI= 71 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 72 | github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= 73 | github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= 74 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 75 | github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af h1:6yITBqGTE2lEeTPG04SN9W+iWHCRyHqlVYILiSXziwk= 76 | github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af/go.mod h1:4F09kP5F+am0jAwlQLddpoMDM+iewkxxt6nxUQ5nq5o= 77 | github.com/urfave/cli/v2 v2.5.1 h1:YKwdkyA0xTBzOaP2G0DVxBnCheHGP+Y9VbKAs4K1Ess= 78 | github.com/urfave/cli/v2 v2.5.1/go.mod h1:oDzoM7pVwz6wHn5ogWgFUU1s4VJayeQS+aEZDqXIEJs= 79 | github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70= 80 | github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= 81 | github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 82 | github.com/ztrue/tracerr v0.3.0 h1:lDi6EgEYhPYPnKcjsYzmWw4EkFEoA/gfe+I9Y5f+h6Y= 83 | github.com/ztrue/tracerr v0.3.0/go.mod h1:qEalzze4VN9O8tnhBXScfCrmoJo10o8TN5ciKjm6Mww= 84 | golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 85 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 86 | golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 87 | golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 88 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= 89 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 90 | golang.org/x/exp v0.0.0-20220428152302-39d4317da171 h1:TfdoLivD44QwvssI9Sv1xwa5DcL5XQr4au4sZ2F2NV4= 91 | golang.org/x/exp v0.0.0-20220428152302-39d4317da171/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= 92 | golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 93 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 94 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 95 | golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 96 | golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI= 97 | golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 98 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 99 | golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 100 | golang.org/x/sys v0.0.0-20180926160741-c2ed4eda69e7/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 101 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 102 | golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 103 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 104 | golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 105 | golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 106 | golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 107 | golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 108 | golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 109 | golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32 h1:Js08h5hqB5xyWR789+QqueR6sDE8mk+YvpETZ+F6X9Y= 110 | golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 111 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 112 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 113 | golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= 114 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 115 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 116 | golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI= 117 | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 118 | golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= 119 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 120 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 121 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 122 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= 123 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 124 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= 125 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 126 | gopkg.in/src-d/go-billy.v4 v4.3.2 h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg= 127 | gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98= 128 | gopkg.in/src-d/go-git-fixtures.v3 v3.5.0 h1:ivZFOIltbce2Mo8IjzUHAFoq/IylO9WHhNOAJK+LsJg= 129 | gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g= 130 | gopkg.in/src-d/go-git.v4 v4.13.1 h1:SRtFyV8Kxc0UP7aCHcijOMQGPxHSmMOPrzulQWolkYE= 131 | gopkg.in/src-d/go-git.v4 v4.13.1/go.mod h1:nx5NYcxdKxq5fpltdHnPa2Exj4Sx0EclMWZQbYDu2z8= 132 | gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= 133 | gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= 134 | gotest.tools/v3 v3.2.0 h1:I0DwBVMGAx26dttAj1BtJLAkVGncrkkUXfJLC4Flt/I= 135 | gotest.tools/v3 v3.2.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A= 136 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "os" 7 | "path/filepath" 8 | 9 | cli "github.com/urfave/cli/v2" 10 | "github.com/ztrue/tracerr" 11 | 12 | "github.com/GitJournal/git-auto-sync/common" 13 | ) 14 | 15 | var version = "dev" 16 | 17 | func main() { 18 | app := &cli.App{ 19 | Name: "git-auto-sync", 20 | Version: version, 21 | Usage: "Automatically Sync any Git Repo", 22 | EnableBashCompletion: true, 23 | Commands: []*cli.Command{ 24 | { 25 | Name: "watch", 26 | Aliases: []string{"monitor", "w", "m"}, 27 | Usage: "Monitor a folder for changes", 28 | Action: func(ctx *cli.Context) error { 29 | repoPath, err := os.Getwd() 30 | if err != nil { 31 | return tracerr.Wrap(err) 32 | } 33 | 34 | repoPath, err = isValidGitRepo(repoPath) 35 | if err != nil { 36 | return tracerr.Wrap(err) 37 | } 38 | 39 | cfg, err := common.NewRepoConfig(repoPath) 40 | if err != nil { 41 | return tracerr.Wrap(err) 42 | } 43 | 44 | return common.WatchForChanges(cfg) 45 | }, 46 | }, 47 | { 48 | Name: "sync", 49 | Aliases: []string{"s"}, 50 | Usage: "Sync a repo right now", 51 | Flags: []cli.Flag{ 52 | &cli.StringSliceFlag{ 53 | Name: "env", 54 | Aliases: []string{"e"}, 55 | Usage: "Env variables to pass", 56 | }, 57 | }, 58 | Action: func(ctx *cli.Context) error { 59 | repoPath, err := os.Getwd() 60 | if err != nil { 61 | return tracerr.Wrap(err) 62 | } 63 | 64 | repoPath, err = isValidGitRepo(repoPath) 65 | if err != nil { 66 | return tracerr.Wrap(err) 67 | } 68 | 69 | cfg, err := common.NewRepoConfig(repoPath) 70 | if err != nil { 71 | return tracerr.Wrap(err) 72 | } 73 | 74 | cfg.Env = append(cfg.Env, ctx.StringSlice("env")...) 75 | 76 | err = common.AutoSync(cfg) 77 | if err != nil { 78 | return tracerr.Wrap(err) 79 | } 80 | 81 | return nil 82 | }, 83 | }, 84 | { 85 | Name: "check", 86 | Usage: "Check if a file will be ignored", 87 | Action: func(ctx *cli.Context) error { 88 | repoPath, err := os.Getwd() 89 | if err != nil { 90 | return tracerr.Wrap(err) 91 | } 92 | 93 | repoPath, err = isValidGitRepo(repoPath) 94 | if err != nil { 95 | return tracerr.Wrap(err) 96 | } 97 | 98 | path := ctx.Args().First() 99 | path, err = filepath.Abs(path) 100 | if err != nil { 101 | return tracerr.Wrap(err) 102 | } 103 | 104 | ignored, err := common.ShouldIgnoreFile(repoPath, path) 105 | if err != nil { 106 | return tracerr.Wrap(err) 107 | } 108 | fmt.Println("Ignored:", ignored) 109 | 110 | return nil 111 | }, 112 | }, 113 | { 114 | Name: "version", 115 | Usage: "Print the version", 116 | Action: func(ctx *cli.Context) error { 117 | cli.VersionPrinter(ctx) 118 | return nil 119 | }, 120 | }, 121 | { 122 | Name: "daemon", 123 | Aliases: []string{"d"}, 124 | Usage: "Interact with the background daemon", 125 | Subcommands: []*cli.Command{ 126 | { 127 | Name: "status", 128 | Usage: "Show the Daemon's status", 129 | Action: daemonStatus, 130 | }, 131 | { 132 | Name: "list", 133 | Aliases: []string{"ls"}, 134 | Usage: "List of repos being auto-synced", 135 | Action: daemonList, 136 | }, 137 | { 138 | Name: "add", 139 | Usage: "Add a repo for auto-sync", 140 | Action: daemonAdd, 141 | }, 142 | { 143 | Name: "remove", 144 | Aliases: []string{"rm"}, 145 | Usage: "Remove a repo from auto-sync", 146 | Action: daemonRm, 147 | }, 148 | { 149 | Name: "env", 150 | Usage: "Set an environment variable", 151 | Action: daemonEnv, 152 | }, 153 | }, 154 | }, 155 | }, 156 | } 157 | 158 | err := app.Run(os.Args) 159 | if err != nil { 160 | log.Fatal(err) 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /todo.md: -------------------------------------------------------------------------------- 1 | * Handle merge / merge-conflict (commit everything, pick newest, notify) 2 | - Add the logs of operation to .git/logs/auto-sync 3 | * Daemon - proper logs 4 | 5 | * CLI auto-complete 6 | 7 | * Add a merge strategy where it doesn't take the YAML header changes into account 8 | * Add a way to only sync some-subfolder in a repo 9 | * Ensure that the 'daemon' process can be found 10 | - It seems it wasn't being installed by the homebrew package 11 | 12 | * Check the state of the git repo before 13 | - Make sure it isn't in the middle of a rebase / merge 14 | - Make sure that head commit is pointing to a branch 15 | - Make sure that branch has a proper remote tracking branch 16 | 17 | * Write about how to handle the case with an ssh-agent running 18 | 19 | * When stopping the daemon, do not do anything if it is not running 20 | 21 | * Avoid these thousands of commits each time one saves a file 22 | - Try to batch them together? 23 | - Or optionally, it should only be saved when the editor is closed 24 | - For vim this means figuring out the backupfile directory 25 | 26 | * Empty files aren't being tracked? This behaviour needs to be documented 27 | 28 | * Add a config checker to make sure things are good 29 | * It doesn't seem to be tracking some deletes? 30 | 31 | * These constant small small commits by Obsidian are annoying me. Have a simple way to do an append commit, and push it every '10 minutes' or so. Do not discount the annoyance caused by this. 32 | --------------------------------------------------------------------------------