Astah with Git

Hi there,
I am Mit, the product owner of system and UML modeling tool Astah.
Thank you for your interest in Astah.

We released version 8.1 of Astah professional / UML / Viewer which changed JavaRuntimeEnvironment and fixed some bugs on Jan 30th. For details click here .

This time, I would like to write about managing Astah files in Git repository.


You have various artifacts through projects such as planning, development, operation, maintenance and project management. I am sure Astah files are also included in it. I think that it is good to use a specialized tool such as Sourcetree in order to handle basic operations on repositories. The problem is how to see the differences between revisions.

Astah provides comparison function of project function. Do you know it can run from the command line? That is “astah-command” command. It is deployed in the installation folder. As shown below, if you specify the two files to be compared with the -diff option and execute it, a screen will be shown to confirm the differences of models and diagrams.

astah-commandw.exe -diff file0.asta file1.asta

By using this command, it is possible to compare revisions of project files of Astah in Git repository. I created a sample command (Widows batch file).
The 1st argument is the hash value of the commit of base file, the 2nd is the hash value of the compared file, and the 3rd is file name.
You can also create a shell script in the same way.

@echo off

rem ---------------------------------------------------------------------------
rem Usage:
rem  astah-git-diff base-revision target-revision filename
rem ---------------------------------------------------------------------------

rem Installed folder of Astah
set ASTAH_DIR=C:\Program Files\astah-professional
rem Path of repository
set REPOSITORY_DIR=C:\Users\m.yamamoto\workspace\repository\astah
rem Working folder
set WORKING_DIR=C:\Users\m.yamamoto\workspace

pushd %~dp0

cd %REPOSITORY_DIR%
set BASE_FILE= "%WORKING_DIR%\%1_%3"
set REF_FILE= "%WORKING_DIR%\%2_%3"

rem get base file
git show  "%1":"%3" > %BASE_FILE%
rem get compared file
git show  "%2":"%3" > %REF_FILE%

rem run Astah command
"%ASTAH_DIR%\astah-commandw.exe" -diff %BASE_FILE% %REF_FILE%

popd

The following is an example of execution.

> astah-git-diff.bat 0123 abcd file.asta

I’ll give you one more tip.
That is how to see the difference between the file being edited and the revision before editing with Sourcetree.

In the options of Sourcetree, set the path to astah-command (.bat instead of .exe on Windows, astah-command.sh on Mac)  at Diff Command, “-diff $LOCAL $REMOTE” at Arguments.
sourcetree-option

You can see the compare project screen by selecting “External Diff” in the pop-up menu with Sourcetree.

git-diff-en


I hope these tips help you.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s