Skip to content

Commit 0b81911

Browse files
heipeipieter
authored andcommitted
About-Panel: Show git-describe using Info.plist
This patch adds a CFBundleGitRevision key to Info.plist which is set to the output of "git describe" when building. The menu-entry for "About GitX" was reconnected to a custom method in the AppController, which reads the CF-string from the .plist and also indicates if the build is a DEBUG-build. Signed-off-by: Johannes Gilger <[email protected]>
1 parent 8cdb2e6 commit 0b81911

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

ApplicationController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
- (NSManagedObjectContext *)managedObjectContext;
2929

3030
- (IBAction)openPreferencesWindow:(id)sender;
31+
- (IBAction)showAboutPanel:(id)sender;
3132

3233
- (IBAction)installCliTool:(id)sender;
3334

ApplicationController.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ - (IBAction)openPreferencesWindow:(id)sender
9292
[[PBPrefsWindowController sharedPrefsWindowController] showWindow:nil];
9393
}
9494

95+
- (IBAction)showAboutPanel:(id)sender
96+
{
97+
NSString *gitversion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleGitVersion"];
98+
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
99+
if (gitversion)
100+
[dict addEntriesFromDictionary:[[NSDictionary alloc] initWithObjectsAndKeys:gitversion, @"Version", nil]];
101+
102+
#ifdef DEBUG_BUILD
103+
[dict addEntriesFromDictionary:[[NSDictionary alloc] initWithObjectsAndKeys:@"GitX (DEBUG)", @"ApplicationName", nil]];
104+
#endif
105+
106+
[NSApp orderFrontStandardAboutPanelWithOptions:dict];
107+
}
108+
95109
- (IBAction)installCliTool:(id)sender;
96110
{
97111
BOOL success = NO;

English.lproj/MainMenu.xib

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,8 +886,8 @@
886886
</object>
887887
<object class="IBConnectionRecord">
888888
<object class="IBActionConnection" key="connection">
889-
<string key="label">orderFrontStandardAboutPanel:</string>
890-
<reference key="source" ref="519751875"/>
889+
<string key="label">showAboutPanel:</string>
890+
<reference key="source" ref="859235683"/>
891891
<reference key="destination" ref="1039244063"/>
892892
</object>
893893
<int key="connectionID">142</int>
@@ -2278,6 +2278,7 @@
22782278
<bool key="EncodedWithXMLCoder">YES</bool>
22792279
<string>installCliTool:</string>
22802280
<string>openPreferencesWindow:</string>
2281+
<string>showAboutPanel:</string>
22812282
<string>saveAction:</string>
22822283
<string>showHelp:</string>
22832284
</object>
@@ -2287,6 +2288,7 @@
22872288
<string>id</string>
22882289
<string>id</string>
22892290
<string>id</string>
2291+
<string>id</string>
22902292
</object>
22912293
</object>
22922294
<object class="NSMutableDictionary" key="outlets">

GitX.xcodeproj/project.pbxproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@
767767
);
768768
runOnlyForDeploymentPostprocessing = 0;
769769
shellPath = /bin/sh;
770-
shellScript = "export PATH=$PATH:$HOME/bin:$HOME/local/bin:/sw/bin:/opt/local/bin:`\"$TARGET_BUILD_DIR\"/gitx --git-path`\nVERSION=$(cd \"$PROJECT_DIR\";git describe)\nLONG_VERSION=$(echo $VERSION | sed -e \"s/\\-/\\./\" -e \"s/^v//\" -e \"s/-.*//\")\nSHORT_VERSION=$(echo $VERSION | sed -e \"s/\\-.*//\" -e \"s/^v//\")\n\necho -n \"#define LONG_VERSION $LONG_VERSION\n#define SHORT_VERSION $SHORT_VERSION\" > \"$PROJECT_TEMP_DIR/revision\"\ntouch Info.plist";
770+
shellScript = "export PATH=$PATH:$HOME/bin:$HOME/local/bin:/sw/bin:/opt/local/bin:`\"$TARGET_BUILD_DIR\"/gitx --git-path`\nVERSION=$(cd \"$PROJECT_DIR\";git describe)\nLONG_VERSION=$(echo $VERSION | sed -e \"s/\\-/\\./\" -e \"s/^v//\" -e \"s/-.*//\")\nSHORT_VERSION=$(echo $VERSION | sed -e \"s/\\-.*//\" -e \"s/^v//\")\n\necho -n \"#define LONG_VERSION $LONG_VERSION\n#define GIT_VERSION $VERSION\n#define SHORT_VERSION $SHORT_VERSION\" > \"$PROJECT_TEMP_DIR/revision\"\ntouch Info.plist";
771771
};
772772
F5792DFB0EDB570C001B0C31 /* Compile libgit2 */ = {
773773
isa = PBXShellScriptBuildPhase;
@@ -985,7 +985,7 @@
985985
HEADER_SEARCH_PATHS = libgit2/src;
986986
INFOPLIST_FILE = Info.plist;
987987
INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional";
988-
INFOPLIST_PREFIX_HEADER = build/revision;
988+
INFOPLIST_PREFIX_HEADER = $PROJECT_TEMP_DIR/revision;
989989
INFOPLIST_PREPROCESS = YES;
990990
INSTALL_PATH = "$(HOME)/Applications";
991991
LIBRARY_SEARCH_PATHS = libgit2;
@@ -1001,6 +1001,7 @@
10011001
GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = DEBUG_BUILD;
10021002
GCC_WARN_ABOUT_RETURN_TYPE = YES;
10031003
GCC_WARN_UNUSED_VARIABLE = YES;
1004+
INFOPLIST_PREPROCESS = YES;
10041005
PREBINDING = NO;
10051006
SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk";
10061007
};
@@ -1016,6 +1017,8 @@
10161017
GCC_ENABLE_OBJC_GC = required;
10171018
GCC_WARN_ABOUT_RETURN_TYPE = YES;
10181019
GCC_WARN_UNUSED_VARIABLE = YES;
1020+
INFOPLIST_PREFIX_HEADER = $PROJECT_TEMP_DIR/revision;
1021+
INFOPLIST_PREPROCESS = YES;
10191022
PREBINDING = NO;
10201023
SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk";
10211024
};
@@ -1084,6 +1087,7 @@
10841087
COPY_PHASE_STRIP = YES;
10851088
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
10861089
GCC_ENABLE_FIX_AND_CONTINUE = NO;
1090+
INFOPLIST_PREPROCESS = YES;
10871091
PRODUCT_NAME = "Generate PList Prefix";
10881092
ZERO_LINK = NO;
10891093
};

Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
<string>????</string>
5151
<key>CFBundleVersion</key>
5252
<string>LONG_VERSION</string>
53+
<key>CFBundleGitVersion</key>
54+
<string>GIT_VERSION</string>
5355
<key>CFBundleShortVersionString</key>
5456
<string>SHORT_VERSION</string>
5557
<key>NSMainNibFile</key>

0 commit comments

Comments
 (0)