1

I have a project that will require reading a local repo and collecting the diff from the most recent commit and the one before it. I then need to do additional work with those diffs (add to an existing log file, make available for tech writers to edit existing API docs with the changes - might Slack them or API into Jira and build a ticket (like that option as it leaves a trail).

I can do the yeoman level work in an AppleScript, calling shell scripts when needed then parsing the data, and passing the cleaned data to the various applications/sites I need to. But other, less technical people will also be using this app and it would be nice to give them a simple UI to work with.

Anyway, after much digging through the Google, SO and other sources I was able to get a MacOS app working that can call an AppleScript and now I've run into a wall...

I can run this AppleScript from Script Editor and it works fine:

set strGitLog to do shell script "cd ~/Desktop/xxxxxx/Projects/UnifiedSDK/Repo/xxxxxx && git log -p -- file1.html"
"commit c39c6bb004d2e104b3f8e15a6125e3d68a5323ef
Author: Steve <xxxxxx@xxxxxx.com>
Date:   Tue Oct 22 15:42:13 2019 -0400

    Added deprecation warning to file1

diff --git a/file1.html b/file1.html
index b7af22b..9fdc781 100644
--- a/file1.html
+++ b/file1.html
@@ -51,6 +51,8 @@
      <h2>Class Description</h2>
      <p style=\"margin-bottom:10px;\">This is the description of the class</p>

+     <p style=\"margin-bottom:10px;\">Warning: This class is scheduled to be deprecated.</p>
+     
      <h3>Arguments:</h3>
      <p style=\"margin-bottom:10px;\">These are the arguments that the class accepts</p>

...

but, if I place this script within a MacOS application:

script gitMessenger

    property parent : class "NSObject"

    to readMessage()
            set strGitLog to do shell script "cd ~/Desktop/xxxxxx/Projects/UnifiedSDK/Repo/xxxxxx && git log -p -- file1.html"
           log strGitLog
    end readMessage

end script

I get this error message in the log:

fatal: Unable to read current working directory: Operation not permitted (error 128)

Which after checking seems to be a Git permissions error. If I pwd I am pointing to the right directory:

/Users/xxxxxx/Library/Containers/xxxxxx.GitMessenger/Data/Desktop/xxxxxx/Projects/UnifiedSDK/Repo/xxxxxx

and that directory has git initiated on it:

enter image description here

and it has permission for read/write to everyone. So I am a little at a loss right now how to get this to work. Any help or suggestions would be appreciated.

PruitIgoe
  • 6,166
  • 16
  • 70
  • 137
  • 1
    Seems more likely it’s just the usual sandboxing. You need user authorization to look in an arbitrary folder like that. Script Editor has authorization but your application doesn’t. You can see that in the Security pref pane. – matt Oct 24 '19 at 20:09
  • 1
    @matt - My bad, should have mentioned I do have my info.plist set up with `Privacy - AppleEvents Sending Usage Description`. Is there something else I need to do to escape the sandboxing? – PruitIgoe Oct 24 '19 at 20:26
  • Has the dialog asking for authorization actually appeared before your eyes? – matt Oct 24 '19 at 20:26
  • Yes, first time I ran it. – PruitIgoe Oct 24 '19 at 20:28
  • Is there a way in XCode to log what permissions the user has agreed to? – PruitIgoe Oct 24 '19 at 20:31
  • Solved it, you put me on the right track. You have to go into your entitlements and set sandbox to false as well as asking for user permission. If you make that an answer I'll give you the bump! Thanks! – PruitIgoe Oct 24 '19 at 20:38
  • 1
    Seems like I would just be duplicating my answer on this question https://stackoverflow.com/questions/55917877/applescript-used-in-my-cocoa-mac-app-stopped-working-in-osx-10-14 and that is not allowed on Stack Overflow. – matt Oct 24 '19 at 20:47

0 Answers0