Harvest

 View Only
  • 1.  Checkout for Concurrent update UDP

    Posted Nov 27, 2023 07:06 AM

    Good day,

    This is going to sound counter-intuitive, but I have my reasons.

    I need a UDP that will check if an item is currently checked out, or if a branch version exists in any state of a project. It would be helpful if it can also provide the user to whom the item is checked out. In certain circumstances I want to prevent concurrent check-outs. However, I don't want to remove concurrent checkouts altogether for that project.

    Kind regards,

    Jarus



    ------------------------------
    Jarus Bosman
    Senior Software Developer
    State Information Technology Agency
    South Africa
    ------------------------------


  • 2.  RE: Checkout for Concurrent update UDP

    Broadcom Employee
    Posted Nov 28, 2023 09:25 AM

    Hello Jarus,

    You should check out the "hsv" command.  It's similar to the "find versions" tool in Workbench.  I think you have to give it a specific state name in your search, but if all new versions originate from the same state, you can search that state and find it no matter where the package is in the lifecycle.  Here's where you can read more: hsv Command-Select Version

    Let me know if this helps.

    Thanks :)

    Melinda



    ------------------------------
    Melinda Skelton
    [JobTitle]
    [CompanyName]
    ------------------------------



  • 3.  RE: Checkout for Concurrent update UDP

    Posted 21 days ago

    Hi Melinda,

    This solution would work if I was able to send the item name and extension to my UDP. However, I only have the ["version"] system variable available, which includes the full path and version number, separated by a semicolon. I find it redundant to have to strip out the item name and extension, this should be provided by Harvest when invoking UDP's. Or am I missing something?

    Regards,

    Jarus



    ------------------------------
    Jarus Bosman
    Senior Software Developer
    State Information Technology Agency
    South Africa
    ------------------------------



  • 4.  RE: Checkout for Concurrent update UDP

    Broadcom Employee
    Posted 21 days ago

    Which operating system is your UDP running in?  I have an idea of maybe running HSV at a broader level - like getting all the files in the state and then "grepping" the result for the file you want.  I will do some testing to see if this might work for what you want to do.

    Thanks :)



    ------------------------------
    Melinda Skelton
    [JobTitle]
    [CompanyName]
    ------------------------------



  • 5.  RE: Checkout for Concurrent update UDP

    Posted 20 days ago

    Hi Melinda,

    We're running on Linux, so my UDP runs a bash script. Your solution above doesn't help, as I still don't have the filename and extension. I've managed to parse it like this:

    #!/bin/bash
    
    # Input string without drive letter (e.g., "\path\to\file.txt;1.23")
    input_string="\path\to\file.txt;1.23"
    
    # Replace backslashes with forward slashes
    normalized_path=$(echo "$input_string" | sed 's/\\/\//g')
    
    # Extract file name and version number
    file_name_with_extension=$(basename "$normalized_path" | cut -d ';' -f 1)
    version_number=$(basename "$normalized_path" | cut -d ';' -f 2)
    
    # Extract file name without extension
    file_name_without_extension=$(echo "$file_name_with_extension" | cut -d '.' -f 1)
    
    # Display results
    echo "File Name with Extension: $file_name_with_extension"
    echo "File Name without Extension: $file_name_without_extension"
    echo "Version Number: $version_number"
    

    I still believe there should be a system variable that returns just the item's filename and extension, without the path and version. I need this in almost all of my UDP's.

    Kind regards,

    Jarus



    ------------------------------
    Jarus Bosman
    Senior Software Developer
    State Information Technology Agency
    South Africa
    ------------------------------



  • 6.  RE: Checkout for Concurrent update UDP

    Broadcom Employee
    Posted 20 days ago

    Do you know the name of the file you're looking for?



    ------------------------------
    Melinda Skelton
    [JobTitle]
    [CompanyName]
    ------------------------------



  • 7.  RE: Checkout for Concurrent update UDP

    Posted 19 days ago

    No, because it's a UDP that can be run on any item. That's why I need a System Variable that returns the item's filename and extension.



    ------------------------------
    Jarus Bosman
    Senior Software Developer
    State Information Technology Agency
    South Africa
    ------------------------------



  • 8.  RE: Checkout for Concurrent update UDP

    Broadcom Employee
    Posted 16 days ago

    You're right.  Harvest does not offer a system variable that can return only the file name without path or version.  That would have to be an enhancement request.

    For now, all I can offer is an easier way to parse the results you get back from the [version] variable so that you get the parts of the result you need.  You and I are thinking along similar lines.  Here's what I came up with:

    $ cat test.sh
    foo=$1
    wholename=$(echo ${foo##*\\} | cut -d';' -f1) ; echo This should remove path and version: $wholename
    filename=${wholename%.*} ; echo This should be the filename only: $filename
    extension=${wholename##*.} ; echo This should be the file extension: $extension
    $

    And it produces this result:

    $ ./test.sh "\SampleRepository\DOCS\README.1.2.3.TXT;1"
    This should remove path and version: README.1.2.3.TXT
    This should be the filename only: README.1.2.3
    This should be the file extension: TXT
    $

    It works with traditional filenames as well:

    $ ./test.sh "\SampleRepository\DOCS\README.TXT;1"
    This should remove path and version: README.TXT
    This should be the filename only: README
    This should be the file extension: TXT
    $

    Let me know if this helps.

    Thanks :)

    Melinda Skelton
    Broadcom Support Team



    ------------------------------
    Melinda Skelton
    [JobTitle]
    [CompanyName]
    ------------------------------