Skip to content

Instantly share code, notes, and snippets.

@clucle
Last active June 22, 2022 01:26

Revisions

  1. clucle revised this gist Jun 22, 2022. 1 changed file with 14 additions and 1 deletion.
    15 changes: 14 additions & 1 deletion p4_trigger_check_file_type.sh
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,7 @@ index=0

    array_depot_file=()
    array_type=()
    array_action=()

    for val in $describe; do
    case "$state" in
    @@ -26,6 +27,14 @@ for val in $describe; do
    substr_index="${val:4}"
    index=$((substr_index+0))
    fi

    substr_action="${val:0:6}"
    if [ "$substr_action" = "action" ]; then
    state="action"
    substr_index="${val:6}"
    index=$((sub_str_index+0))
    fi

    ;;
    "depotFile")
    array_depot_file[$index]=$val
    @@ -35,14 +44,18 @@ for val in $describe; do
    array_type[$index]=$val
    state="..."
    ;;
    "action")
    array_action[$index]=$val
    state="..."
    ;;
    esac
    done

    check=0
    for (( i=0; i <${#array_depot_file[@]}; i++ ));
    do
    ext="${array_depot_file[$i]##*.}"
    if [ "$ext" = "uasset" ]; then
    if [ "$ext" = "uasset" ] && [ "${array_action[$i]}" != "delete" ]; then
    if [[ "${array_type[$i]}" == *"+"*"l"* ]]; then
    :
    else
  2. clucle revised this gist Jun 22, 2022. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions p4_trigger_check_file_type.sh
    Original file line number Diff line number Diff line change
    @@ -2,9 +2,6 @@ WORKSPACENAME=$1
    CHANGELIST=$2

    P4="p4 -C utf8 -u username -P password"
    LOG_PATH="/YOUR_LOG_PATH"

    touch $LOG_PATH

    describe=$(eval "$P4 -Ztag describe $CHANGELIST")
    state="..."
  3. clucle created this gist Jun 18, 2022.
    63 changes: 63 additions & 0 deletions p4_trigger_check_file_type.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,63 @@
    WORKSPACENAME=$1
    CHANGELIST=$2

    P4="p4 -C utf8 -u username -P password"
    LOG_PATH="/YOUR_LOG_PATH"

    touch $LOG_PATH

    describe=$(eval "$P4 -Ztag describe $CHANGELIST")
    state="..."
    index=0

    array_depot_file=()
    array_type=()

    for val in $describe; do
    case "$state" in
    "...")
    substr_depot_file="${val:0:9}"
    if [ "$substr_depot_file" = "depotFile" ]; then
    state="depotFile"
    substr_index="${val:9}"
    index=$((substr_index+0))
    fi

    substr_type="${val:0:4}"
    if [ "$substr_type" = "type" ]; then
    state="type"
    substr_index="${val:4}"
    index=$((substr_index+0))
    fi
    ;;
    "depotFile")
    array_depot_file[$index]=$val
    state="..."
    ;;
    "type")
    array_type[$index]=$val
    state="..."
    ;;
    esac
    done

    check=0
    for (( i=0; i <${#array_depot_file[@]}; i++ ));
    do
    ext="${array_depot_file[$i]##*.}"
    if [ "$ext" = "uasset" ]; then
    if [[ "${array_type[$i]}" == *"+"*"l"* ]]; then
    :
    else
    echo "${array_depot_file[$i]} 파일은+l 속성이어야 합니다"
    check=$((check+1))
    fi
    fi
    done

    if (( $check > 0 )); then
    echo "파일 타입 변경이 필요합니다"
    exit 1
    fi

    exit 0