Macro Scheduler with Git

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
MarcinW
Junior Coder
Posts: 24
Joined: Thu Jul 23, 2020 11:24 pm

Macro Scheduler with Git

Post by MarcinW » Fri Jul 24, 2020 9:31 am

Hi everyone,

I've been using Macro Scheduler to develop bots for my company for quite a while now.
Currently our team is expanding and so does the amount of scripts that we have, for this reason we decided that we will need to use git for version control.

The problem with this is that git recognises .scp files as binary files, therefore, we are not able to see differences between the files using "git diff" command. We can force it to be shown using "git diff --text" but obviously that does not display the text in readable format.

I was wondering if anyone here already used MS with Git and could help me resolve this issue to view difference in .scp files. The only thing I can think of currently is to have a txt copy of each script, but I would prefer too see diff straight in the .scp files. Any ideas?

Thanks in advance.

User avatar
Grovkillen
Automation Wizard
Posts: 1128
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Macro Scheduler with Git

Post by Grovkillen » Fri Jul 24, 2020 12:33 pm

Shouldn't GitHub interpret any UTF-8 or ASCII as a text file?
Let>ME=%Script%

Running: 15.0.27
version history

MarcinW
Junior Coder
Posts: 24
Joined: Thu Jul 23, 2020 11:24 pm

Re: Macro Scheduler with Git

Post by MarcinW » Fri Jul 24, 2020 4:37 pm

Hi Grovkillen, I checked what the character encoding of scp file is within notepad++. It appears to be "UCS-2 LE BOM" which is a 16-bit Unicode encoding.

Is there any setting that allows to change the character encoding to UTF-8 in Macro Scheduler files?

User avatar
Grovkillen
Automation Wizard
Posts: 1128
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Macro Scheduler with Git

Post by Grovkillen » Fri Jul 24, 2020 7:50 pm

If you open them in Notepad++ and change the document encoding, will it still revert that upon save in MS?
Let>ME=%Script%

Running: 15.0.27
version history

MarcinW
Junior Coder
Posts: 24
Joined: Thu Jul 23, 2020 11:24 pm

Re: Macro Scheduler with Git

Post by MarcinW » Mon Jul 27, 2020 10:36 pm

Yes, I changed the encoding to "utf-8", saved script in MS, checked back in notepad++ and it was "ucs-2 le bom" again.

I went through whole of MS and couldn't find any setting for encoding, I've also been looking online for any git command that would change encoding for viewing differences between files, couldn't find any but found two CMD commands:

iconv -f UCS-2LE -t UTF-8 test-encoding.scp > test-encoding-2.scp
move /y test-encoding-2.scp test-encoding.scp

First one creates copy of file with encoding converted from "UCS-2 LE BOM" into "UTF-8 BOM". Second one makes the copy overwrite the original file. Files with this new encoding work properly with diff. I am thinking of creating a batch file that would convert all files in the directory this way. It would need to be ran each time before diff or push.

Unless you have any other ideas that might be better?

User avatar
Grovkillen
Automation Wizard
Posts: 1128
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Macro Scheduler with Git

Post by Grovkillen » Tue Jul 28, 2020 5:11 am

Hmm, perhaps Marcus could shed some light on this. I would like to know if the .SCP files need to be encoded as such or if it would be possible to have it changed in the settings.

So for your problem, yes I would also do a batch conversion like you suggested.
Let>ME=%Script%

Running: 15.0.27
version history

MarcinW
Junior Coder
Posts: 24
Joined: Thu Jul 23, 2020 11:24 pm

Re: Macro Scheduler with Git

Post by MarcinW » Fri Jul 31, 2020 3:51 pm

Thanks for your help, it would be nice if Marcus could have a look into it too.

User avatar
Marcus Tettmar
Site Admin
Posts: 7393
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Macro Scheduler with Git

Post by Marcus Tettmar » Sun Aug 02, 2020 1:56 pm

Macro Scheduler script files are unicode. We don't offer a way to change that and if you do change the encoding you are likely to corrupt your scripts at worst and at best will not be able to see your code in the built in editor.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Grovkillen
Automation Wizard
Posts: 1128
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Macro Scheduler with Git

Post by Grovkillen » Sun Aug 02, 2020 2:14 pm

So the best would then be to do a batch script that copy each file and perhaps give them the file extension of ".SCPGIT" or something. Thanks for the feedback Marcus.
Let>ME=%Script%

Running: 15.0.27
version history

September
Newbie
Posts: 4
Joined: Thu Apr 27, 2023 1:00 am

Re: Macro Scheduler with Git

Post by September » Thu Apr 27, 2023 1:05 am

Adding:

*.scp text working-tree-encoding=UCS-2LE eol=CRLF

to the .gitattributes file seems to have done the trick. Ignore BOM.

This helped: https://stackoverflow.com/questions/281 ... inary-file

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts