Skip to content

Commit

Permalink
added a version string to the prefs window
Browse files Browse the repository at this point in the history
  • Loading branch information
moshee committed Mar 30, 2014
1 parent ee43d37 commit 2d2b6ca
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Airlift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/bash;
shellScript = "#!/bin/bash\n\n# This script automatically sets the version and short version string of\n# an Xcode project from the Git repository containing the project.\n#\n# To use this script in Xcode 4, add the contents to a \"Run Script\" build\n# phase for your application target.\n\nexit\n\nset -o errexit\nset -o nounset\n\n# First, check for git in $PATH\nhash git 2>/dev/null || { echo >&2 \"Git required, not installed. Aborting build number update script.\"; exit 0; }\n\n# Alternatively, we could use Xcode's copy of the Git binary,\n# but old Xcodes don't have this.\n#GIT=$(xcrun -find git)\n\n# Run Script build phases that operate on product files of the target that defines them should use the value of this build setting [TARGET_BUILD_DIR]. But Run Script build phases that operate on product files of other targets should use “BUILT_PRODUCTS_DIR” instead.\nINFO_PLIST=\"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}\"\n\n# Build version (closest-tag-or-branch \"-\" commits-since-tag \"-\" short-hash dirty-flag)\nBUILD_VERSION=$(git describe --tags --always --dirty=+)\n\n# Use the latest tag for short version (expected tag format \"n[.n[.n]]\")\nLATEST_TAG=$(git describe --tags --abbrev=0)\nCOMMIT_COUNT_SINCE_TAG=$(git rev-list --count ${LATEST_TAG}..)\nif [ $LATEST_TAG = \"start\" ]; then\n LATEST_TAG=0\nfi\n\nif [ $COMMIT_COUNT_SINCE_TAG = 0 ]; then\n SHORT_VERSION=\"$LATEST_TAG\"\nelse\n# increment final digit of tag and append \"d\" + commit-count-since-tag\n# e.g. commit after 1.0 is 1.1d1, commit after 1.0.0 is 1.0.1d1\n# this is the bit that requires /bin/bash\n OLD_IFS=$IFS\n IFS=\".\"\n VERSION_PARTS=($LATEST_TAG)\n LAST_PART=$((${#VERSION_PARTS[@]}-1))\n VERSION_PARTS[$LAST_PART]=$((${VERSION_PARTS[${LAST_PART}]}+1))\n SHORT_VERSION=\"${VERSION_PARTS[*]}+${COMMIT_COUNT_SINCE_TAG}\"\n IFS=$OLD_IFS\nfi\n \n # Bundle version (commits-on-master[-until-branch \".\" commits-on-branch])\n # Assumes that two release branches will not diverge from the same commit on master.\nif [ $(git rev-parse --abbrev-ref HEAD) = \"master\" ]; then\n MASTER_COMMIT_COUNT=$(git rev-list --count HEAD)\n BRANCH_COMMIT_COUNT=0\n BUNDLE_VERSION=\"$MASTER_COMMIT_COUNT\"\nelse\n MASTER_COMMIT_COUNT=$(git rev-list --count $(git rev-list master.. | tail -n 1)^)\n BRANCH_COMMIT_COUNT=$(git rev-list --count master..)\n if [ $BRANCH_COMMIT_COUNT = 0 ]; then\n BUNDLE_VERSION=\"$MASTER_COMMIT_COUNT\"\n else\n BUNDLE_VERSION=\"${MASTER_COMMIT_COUNT}.${BRANCH_COMMIT_COUNT}\"\n fi\nfi\n \n defaults write \"$INFO_PLIST\" CFBundleBuildVersion \"$BUILD_VERSION\"\n defaults write \"$INFO_PLIST\" CFBundleShortVersionString \"$SHORT_VERSION\"\n defaults write \"$INFO_PLIST\" CFBundleVersion \"$BUNDLE_VERSION\"";
shellScript = "#!/bin/bash\n\n# This script automatically sets the version and short version string of\n# an Xcode project from the Git repository containing the project.\n#\n# To use this script in Xcode 4, add the contents to a \"Run Script\" build\n# phase for your application target.\n\nset -o errexit\nset -o nounset\n\n# First, check for git in $PATH\nhash git 2>/dev/null || { echo >&2 \"Git required, not installed. Aborting build number update script.\"; exit 0; }\n\n# Alternatively, we could use Xcode's copy of the Git binary,\n# but old Xcodes don't have this.\n#GIT=$(xcrun -find git)\n\n# Run Script build phases that operate on product files of the target\n# that defines them should use the value of this build setting\n# [TARGET_BUILD_DIR]. But Run Script build phases that operate on product\n# files of other targets should use “BUILT_PRODUCTS_DIR” instead.\nINFO_PLIST=\"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}\"\n\n# Build version (closest-tag-or-branch \"-\" commits-since-tag \"-\" short-hash dirty-flag)\nBUILD_VERSION=$(git describe --tags --always --dirty=+)\n\n# Use the latest tag for short version (expected tag format \"n[.n[.n]]\")\nLATEST_TAG=$(git describe --tags --abbrev=0)\nCOMMIT_COUNT_SINCE_TAG=$(git rev-list --count ${LATEST_TAG}..)\nif [ $LATEST_TAG = \"start\" ]; then\n LATEST_TAG=0\nfi\n\nif [ $COMMIT_COUNT_SINCE_TAG = 0 ]; then\n SHORT_VERSION=\"$LATEST_TAG\"\nelse\n# increment final digit of tag and append \"d\" + commit-count-since-tag\n# e.g. commit after 1.0 is 1.1d1, commit after 1.0.0 is 1.0.1d1\n# this is the bit that requires /bin/bash\n OLD_IFS=$IFS\n IFS=\".\"\n VERSION_PARTS=($LATEST_TAG)\n LAST_PART=$((${#VERSION_PARTS[@]}-1))\n VERSION_PARTS[$LAST_PART]=$((${VERSION_PARTS[${LAST_PART}]}+1))\n SHORT_VERSION=\"${VERSION_PARTS[*]}+${COMMIT_COUNT_SINCE_TAG}\"\n IFS=$OLD_IFS\nfi\n \n # Bundle version (commits-on-master[-until-branch \".\" commits-on-branch])\n # Assumes that two release branches will not diverge from the same commit on master.\nif [ $(git rev-parse --abbrev-ref HEAD) = \"master\" ]; then\n MASTER_COMMIT_COUNT=$(git rev-list --count HEAD)\n BRANCH_COMMIT_COUNT=0\n BUNDLE_VERSION=\"$MASTER_COMMIT_COUNT\"\nelse\n MASTER_COMMIT_COUNT=$(git rev-list --count $(git rev-list master.. | tail -n 1)^)\n BRANCH_COMMIT_COUNT=$(git rev-list --count master..)\n if [ $BRANCH_COMMIT_COUNT = 0 ]; then\n BUNDLE_VERSION=\"$MASTER_COMMIT_COUNT\"\n else\n BUNDLE_VERSION=\"${MASTER_COMMIT_COUNT}.${BRANCH_COMMIT_COUNT}\"\n fi\nfi\n\n # defaults write \"$INFO_PLIST\" CFBundleBuildVersion \"$BUILD_VERSION\"\n defaults write \"$INFO_PLIST\" CFBundleShortVersionString \"$SHORT_VERSION\"\n defaults write \"$INFO_PLIST\" CFBundleVersion \"$BUNDLE_VERSION\"\n #defaults write \"$INFOPLIST_FILE\" CFBundleShortVersionString \"$SHORT_VERSION\"\n #defaults write \"$INFOPLIST_FILE\" CFBundleVersion \"$BUNDLE_VERSION\"";
showEnvVarsInLog = 0;
};
4E90AEE718E6992200A50247 /* ShellScript */ = {
Expand Down
2 changes: 2 additions & 0 deletions Airlift/ALPreferenceViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
IBOutlet NSSecureTextField* passwordField;
}

@property (retain) NSString* versionString;

- (IBAction)didEnterHostname:(id)sender;
- (IBAction)didEnterPassword:(id)sender;

Expand Down
9 changes: 9 additions & 0 deletions Airlift/ALPreferenceViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

@implementation ALPreferenceViewController

@synthesize versionString;

static NSString* serviceName = @"airlift";

- (id)initWithCoder:(NSCoder*)aDecoder {
Expand All @@ -29,6 +31,13 @@ - (id)initWithCoder:(NSCoder*)aDecoder {
[hostField setStringValue:host];
[passwordField setStringValue:password];
}

NSDictionary* infoPlist = [[NSBundle mainBundle] infoDictionary];
NSString* shortVersion =
[infoPlist valueForKeyPath:@"CFBundleShortVersionString"];
NSString* version = [infoPlist valueForKeyPath:@"CFBundleVersion"];
self.versionString =
[NSString stringWithFormat:@"Airlift %@ (%@)", shortVersion, version];
}

return self;
Expand Down
28 changes: 20 additions & 8 deletions Airlift/ALPreferenceViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<customView id="1">
<rect key="frame" x="0.0" y="0.0" width="365" height="152"/>
<rect key="frame" x="0.0" y="0.0" width="365" height="182"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ggP-Aq-0oM">
<rect key="frame" x="64" y="100" width="47" height="17"/>
<rect key="frame" x="64" y="130" width="47" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Server:" id="i7z-fG-cBL">
<font key="font" metaFont="system"/>
Expand All @@ -29,7 +29,7 @@
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="IrO-Bt-Luf">
<rect key="frame" x="117" y="97" width="148" height="22"/>
<rect key="frame" x="117" y="127" width="148" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="http://i.example.com" drawsBackground="YES" usesSingleLineMode="YES" id="sv7-GC-m2h">
<font key="font" metaFont="system"/>
Expand All @@ -41,7 +41,7 @@
</connections>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ej2-Fs-xjo">
<rect key="frame" x="273" y="97" width="50" height="22"/>
<rect key="frame" x="273" y="127" width="50" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="60606" drawsBackground="YES" id="2i8-jE-EMk">
<font key="font" metaFont="system"/>
Expand All @@ -53,7 +53,7 @@
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="HFk-rw-0Qd">
<rect key="frame" x="45" y="68" width="66" height="17"/>
<rect key="frame" x="45" y="98" width="66" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Password:" id="Yml-l7-3BU">
<font key="font" metaFont="system"/>
Expand All @@ -62,7 +62,7 @@
</textFieldCell>
</textField>
<secureTextField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9di-Da-EKP">
<rect key="frame" x="117" y="65" width="206" height="22"/>
<rect key="frame" x="117" y="95" width="206" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<secureTextFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" usesSingleLineMode="YES" id="GrU-Ba-SrX">
<font key="font" metaFont="system"/>
Expand All @@ -77,7 +77,7 @@
</connections>
</secureTextField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7O1-f7-34V">
<rect key="frame" x="265" y="100" width="9" height="17"/>
<rect key="frame" x="265" y="130" width="9" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title=":" id="aqc-Hx-Djq">
<font key="font" metaFont="system"/>
Expand All @@ -86,7 +86,7 @@
</textFieldCell>
</textField>
<button toolTip="Example: uploading &quot;image.jpg&quot; would return &quot;http://i.example.com/f9G2.jpg&quot; instead of &quot;http://i.example.com/f9G2&quot;" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Jx1-BW-FBZ">
<rect key="frame" x="28" y="30" width="308" height="20"/>
<rect key="frame" x="28" y="60" width="308" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Append filename extension to returned URLs" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="5GV-RM-QLJ">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
Expand All @@ -96,6 +96,18 @@
<binding destination="2eN-FZ-YlG" name="value" keyPath="values.appendExtensions" id="fyq-Vj-EmA"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="YMt-t6-LY0">
<rect key="frame" x="90" y="20" width="185" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="center" title="Airlift" usesSingleLineMode="YES" id="xKh-LE-wqr">
<font key="font" metaFont="system"/>
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<binding destination="-2" name="value" keyPath="versionString" id="K0I-vR-zda"/>
</connections>
</textField>
</subviews>
</customView>
<userDefaultsController representsSharedInstance="YES" id="2eN-FZ-YlG"/>
Expand Down

0 comments on commit 2d2b6ca

Please sign in to comment.