Sha256: 1801dc42c22e8862adb8b9874d3fdb089b90d6912c6a852d474e3a86349c73e3

Contents?: true

Size: 1.66 KB

Versions: 11

Compression:

Stored size: 1.66 KB

Contents

#!/bin/sh -e

# Created by Yuri Govorushchenko on 22/05/2013.
# Copyright 2013 nix. All rights reserved.

# Script reverts all changes in working copy and removes unversioned files.

currentScriptDir=$(cd "$(dirname "$0")"; pwd)
SCM_TYPE=$("${currentScriptDir}/DetectSCM.sh")

cleanAll=$1

CLEAN_ALL=0
if [ "${cleanAll}" == "all" ]; then
    echo "--- Clean all specified"
    CLEAN_ALL=1
fi

# Subversion
if [[ "${SCM_TYPE}" = "svn" ]]; then
    echo "SVN working copy detected, cleaning..."

    # revert all changes
    svn revert --depth=infinity "./"

    # revert all changes in external directories
    for i in $(svn status | grep ^Performing | cut -d\' -f 2)
    do
        svn revert -R $i
    done

    # wipe out unversioned files
    perl "${currentScriptDir}/svn-clean.pl" "./"

# git
elif [[ "${SCM_TYPE}" = "git" ]]; then
    echo "GIT working copy detected, cleaning..."

    # revert all changes
    git reset --hard

    if [ ${CLEAN_ALL} -eq 1 ]; then
        # wipe out unversioned files (force, remove whole directories, remove ignored files)
        git clean -fdx
    else
        # wipe out unversioned files (force, remove whole directories)
        git clean -fd
    fi

# mercurial
elif [[ "${SCM_TYPE}" = "mercurial" ]]; then
    echo "Mercurial working copy detected, cleaning..."

    # revert all changes
    hg revert --all

    if [ ${CLEAN_ALL} -eq 1 ]; then
        # wipe out unversioned files
        hg --config extensions.purge= clean --all
    else
        # wipe out unversioned files (except ignored files)
        hg --config extensions.purge= clean
    fi

# undefined SCM
else
    echo "error: script must be run from working copy" 1>&2
    exit 1
fi

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
nixenvironment-0.0.70 legacy/CleanWorkingCopy.sh
nixenvironment-0.0.69 legacy/CleanWorkingCopy.sh
nixenvironment-0.0.68 legacy/CleanWorkingCopy.sh
nixenvironment-0.0.67 legacy/CleanWorkingCopy.sh
nixenvironment-0.0.66 legacy/CleanWorkingCopy.sh
nixenvironment-0.0.65 legacy/CleanWorkingCopy.sh
nixenvironment-0.0.64 legacy/CleanWorkingCopy.sh
nixenvironment-0.0.63 legacy/CleanWorkingCopy.sh
nixenvironment-0.0.62 legacy/CleanWorkingCopy.sh
nixenvironment-0.0.61 legacy/CleanWorkingCopy.sh
nixenvironment-0.0.60 legacy/CleanWorkingCopy.sh