Re: Question about DITA launcher inside a Cygwin environment #Oxygen


Mica Semrick
 

I'd expect that since you are using windows, git, when run from oxygen, has no knowledge of your cygwin environment and thus cannot launch your script with bash.

I'd guess that you'd need to give the file an extension, like .sh, then associate the .sh mimetype with bash.

-m


On January 10, 2020 7:51:46 AM PST, Grant Hogarth <grant.hogarth@...> wrote:
Hello;
I'm trying to create a workflow that starts with multiple DITA files inside oXygen that end up as a single md file in GitHub.
I have installed the GitHub plugin (built on on the JGit library) in oXygen so that I can commit to a GitHub repository.
When I make the commit, I am trying to make a DITA-OT call using pre-commit githooks. The githooks script calls DITA-OT and uses it to merge the files before submitting them as a single file.
Unfortunately, this is not working.
The script (see below) works as expected when run from a GitBash or Windows command window. But running it from within oXygen appears to ignore the githooks.
Environment: Windows 10, Cygwin 3.0.7-1, DITA-OT 3.4, Java 11+28.
----
Githooks Script
#!/bin/sh set -x # In order to run this pre-commit hook the user will need the following setup # 1. The DITA-OT command utility needs to be added to the path # In Windows, typically this path is: "C:\DEV\DITA-OT\dita-ot-3.4\bin" # 2. Git needs to be installed on your computer. (https://git-scm.com/download/) # 3. Run 'git config core.hooksPath .githooks' in the repo folder to add the Git symlink. # There is no confirmation. # 3. Run 'chmod +x .githooks/pre-commit' in the repo folder to add the Git symlink. # There is no confirmation. # Populate all the .DITA* files for this commit ditafiles=$(git diff --cached --name-only --diff-filter=ACM | grep '.dita*') # Get the absolute path of the `.git/hooks` directory export GIT_HOOKS=`cd "\`dirname "\\\`readlink "$0" || echo $0\\\`"\`" && pwd` # Loop over the files, find their directory, and generate the README within that directory for arg in $ditafiles; do BASE_DIRECTORY=$(echo "$arg" | cut -d "/" -f1) # Set the absolute path of the build directory export BUILD_FILES="$GIT_HOOKS/../$BASE_DIRECTORY" # Now that we have the base path to the project we can run the DITA command to generate that specific README dita --input=$BUILD_FILES/README.ditamap --format=markdown -Dchunk=to-content --output=$BUILD_FILES/docs/ done # Exit with status of last command exit 0  
------
The JAVA_HOME variable user path (not system path, if that makes a difference) points to jdk-11.
Running the following in a Git Bash window works.
git add . 
git commit -m "bash commit"

As this is basically the commands generated from the other code sample above, I'm stumped, as is the support person at oXygen.
  The following is the response I got from the oXygen support person:  
I tried to use your script as a pre-commit hook, myself. I've started Oxygen from the command line launcher because I've noticed that if the pre-commit hook uses echo command then I will see its output inside Oxygen's console. When I committed from Oxygen, what appeared in the console was just this line:

CODE: SELECT ALL

Buildfile: \cygdrive\d\projects\oxygen\frameworks\dita\DITA-OT3.x\build.xml does not exist!
I've noticed that the dita script has some logic to identify when it's being executed in cygwin context, but I can't actually say what it's doing in there. I've made another small test:
- the dita script was added in my path, like we've previously discussed
- I've started a cygwin console
- I've execute the command:

CODE: SELECT ALL

dita --input=README.ditamap --format=markdown -Dchunk=to-content --output=docs/
I've received the same output:

CODE: SELECT ALL

Buildfile: \cygdrive\d\projects\eXml\frameworks\dita\DITA-OT3.x\build.xml does not exist!
Error: Error: Build failed
So it would appear that the dita launcher doesn't work inside a cygwin environment...    

Is this true, or are there other settings that need to be made?
Regards,
Grant Hogarth 
Technical Writer, SA Tools
Workiva Inc. 
1700 Platte St, Suite 200, Denver, Colorado 80202 
Mobile: 1-801-815-8353 

Join main@dita-users.groups.io to automatically receive all group messages.