All Projects → kolbasa → Git Repo Watcher

kolbasa / Git Repo Watcher

Licence: mit
A simple bash script to watch a git repository and pull upstream changes if needed.

Programming Languages

shell
77523 projects
bash
514 projects

Projects that are alternatives of or similar to Git Repo Watcher

Denon
👀 Monitor any changes in your Deno application and automatically restart.
Stars: ✭ 725 (+893.15%)
Mutual labels:  daemon, watch, watcher
watcher
The file system watcher that strives for perfection, with no native dependencies and optional rename detection support.
Stars: ✭ 37 (-49.32%)
Mutual labels:  watch, watcher
cheap-watch
If it works, why use something else? // Mirror of https://git.chor.date/Conduitry/cheap-watch
Stars: ✭ 64 (-12.33%)
Mutual labels:  watch, watcher
toxic-decorators
Library of Javascript decorators
Stars: ✭ 26 (-64.38%)
Mutual labels:  watch, watcher
pwatch
Process watcher(pwatch)
Stars: ✭ 33 (-54.79%)
Mutual labels:  watch, watcher
Swatch
Watcher for Unit Tests written in Swift
Stars: ✭ 55 (-24.66%)
Mutual labels:  daemon, watcher
compose-watcher
Watch volumes and restart services in docker compose
Stars: ✭ 27 (-63.01%)
Mutual labels:  watch, watcher
Gitconverter
Синхронизация хранилища конфигурации "1С:Предприятия" с репозиторием Git и последующим переходом на разработку в 1C:Enterprise Development Tools (1C:EDT) с сохранением истории
Stars: ✭ 149 (+104.11%)
Mutual labels:  sync, repository
Monstache
a go daemon that syncs MongoDB to Elasticsearch in realtime
Stars: ✭ 736 (+908.22%)
Mutual labels:  daemon, sync
Sync
syncs your local folder with remote folder using scp
Stars: ✭ 293 (+301.37%)
Mutual labels:  sync, remote
gowatch
watch go files for developer, support run test case and auto reload server application
Stars: ✭ 18 (-75.34%)
Mutual labels:  watch, watcher
Multiwatch
Simple task runner on directory changes that doesn't produce tons of logs if everything is OK 👌
Stars: ✭ 74 (+1.37%)
Mutual labels:  watch, watcher
Beefun Pro
Github client for iOS in Swift.
Stars: ✭ 172 (+135.62%)
Mutual labels:  watch, repository
installer
remote.it command line installer tool
Stars: ✭ 21 (-71.23%)
Mutual labels:  daemon, remote
Funzzy
Yet another fancy watcher. (Rust)
Stars: ✭ 142 (+94.52%)
Mutual labels:  watch, watcher
git-repo-name
Get the repository name from the git remote origin URL
Stars: ✭ 21 (-71.23%)
Mutual labels:  repository, remote
ferryd
Fast, safe and reliable transit for the delivery of software updates to users.
Stars: ✭ 43 (-41.1%)
Mutual labels:  repository, daemon
Proxy Watcher
A library that recursively watches an object for mutations via Proxies and tells you which paths changed.
Stars: ✭ 35 (-52.05%)
Mutual labels:  watch, watcher
Pebble
Unofficial Pebble watch support for SailfishOS/Jolla
Stars: ✭ 71 (-2.74%)
Mutual labels:  daemon, watch
Gh Card
GitHub Repository Card for Any Web Site
Stars: ✭ 1,154 (+1480.82%)
Mutual labels:  repository

Git Repo Watcher

A simple bash script to watch a git repository and pull upstream changes if available.

Requirements

Basically, it will work anywhere you can install Bash.

If something doesn't work, please let me know.

Usage

You only need the path to your git repository to start.

This will start a watcher that looks for changes every 10 seconds:

./git-repo-watcher -d "/path/to/your/repository"

The time interval can be changed by passing it to -i:

./git-repo-watcher -d "/path/to/your/repository" -i 60 #seconds

Make sure your local repository is tracking a remote branch, otherwise the script will fail.

Customizations

You can add your own logic to the file: git-repo-watcher-hooks

For example, you can start your build process in case of changes:

# $1 - Git repository name
# $2 - Branch name
# $3 - Commit details
change_pulled() {
    echo "Starting build for commit: [email protected]"
    ./your-build-script.sh
}

If you have more than one repository you can pass a copy of the git-repo-watcher-hooks file like so:

./git-repo-watcher -d "/path/to/your/repository" -h "/path/to/your/hooks-file"

Private repositories

The script works with private repositories.

First configure a password cache with git config --global credential.helper "cache --timeout=60".
Make sure the timeout is greater than the time interval given to the script. Both are given as seconds.
The program will execute git fetch and ask for your login data. The script itself does not store passwords!

If you want it to run in the background as a daemon process, you have to execute git fetch beforehand.

Example code:

cd "/path/to/your/repository"
git config --global credential.helper "cache --timeout=60"
git fetch

# Checking exit code
if [[ $? -eq 1 ]]; then
    echo "Wrong password!" >&2
    exit 1
fi

# Disown process
./git-repo-watcher -d "/path/to/your/repository" > "/path/to/your/logfile.log" & disown

Windows 10

The easiest way is to install Git Shell, which also comes with bash.
The only thing you have to consider are the file separators. The Unix format should be used here:

C:\YourGitRepository/C/YourGitRepository

It is a little more difficult with WSL.
This must first be installed and configured via the Windows Store. The file structure is also slightly different:

C:\YourGitRepository/mnt/c/YourGitRepository

Tests

The test suite git-repo-watcher-tests is using the test framework shunit2, it will be downloaded automatically to your /tmp folder.
The script has no other dependencies and requires no internet connection.

The tests create several test git repositories in the folder: /tmp/git-repo-watcher.

A git user should be configured, otherwise the tests will fail.
With the following line you can check if this is the case:

git config --list

You can configure it as follows:

git config --global user.email "[email protected]"
git config --global user.name "Your Name"
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].