Esempio n. 1
0
def main(argv):

    # Locate the root of the buck repo.  We'll need to be there to
    # generate the buck version UID.
    path = os.getcwd()
    while not os.path.exists(os.path.join(path, '.buckconfig')):
        path = os.path.dirname(path)

    if os.path.exists(os.path.join(path, '.git')):
        # Attempt to create a "clean" version, but fall back to a "dirty"
        # one if need be.
        version = buck_version.get_clean_buck_version(path)
        timestamp = -1
        if version is None:
            version = buck_version.get_dirty_buck_version(path)
        else:
            timestamp = buck_version.get_git_revision_timestamp(path)
    else:
        # We're building outside a git repo. Check for the special
        # .buckrelease file created by the release process.
        try:
            with open(os.path.join(path, '.buckrelease')) as f:
                timestamp = int(os.fstat(f.fileno()).st_mtime)
                version = f.read().strip()
        except IOError, e:
            if e.errno == errno.ENOENT:
                # No .buckrelease file. Do the best that we can.
                version = '(unknown version)'
                timestamp = int(time.time())
            else:
                raise e
Esempio n. 2
0
def main(argv):

    # Locate the root of the buck repo.  We'll need to be there to
    # generate the buck version UID.
    path = os.getcwd()
    while not os.path.exists(os.path.join(path, '.buckconfig')):
        path = os.path.dirname(path)

    if os.path.exists(os.path.join(path, '.git')):
        # Attempt to create a "clean" version, but fall back to a "dirty"
        # one if need be.
        version = buck_version.get_clean_buck_version(path)
        timestamp = -1
        if version is None:
            version = buck_version.get_dirty_buck_version(path)
        else:
            timestamp = buck_version.get_git_revision_timestamp(path)
    else:
        # We're building outside a git repo. Check for the special
        # .buckrelease file created by the release process.
        try:
            with open(os.path.join(path, '.buckrelease')) as f:
                timestamp = int(os.fstat(f.fileno()).st_mtime)
                version = f.read().strip()
        except IOError, e:
            if e.errno == errno.ENOENT:
                # No .buckrelease file. Do the best that we can.
                version = '(unknown version)'
                timestamp = int(time.time())
            else:
                raise e
Esempio n. 3
0
def main(argv):
    parser = argparse.ArgumentParser()
    parser.add_argument("--release-version", help="The buck release version")
    parser.add_argument("--release-timestamp",
                        help="The unix timestamp when the release happened")
    args = parser.parse_args(argv[1:])
    if bool(args.release_version) != bool(args.release_timestamp):
        print("--release-version and --release-timestamp must either both be "
              "set, or neither can be set")
        sys.exit(1)

    # Locate the root of the buck repo.  We'll need to be there to
    # generate the buck version UID.
    path = os.getcwd()
    while not os.path.exists(os.path.join(path, ".buckconfig")):
        path = os.path.dirname(path)

    if args.release_version:
        version = args.release_version
        timestamp = args.release_timestamp
        dirty = False
    elif os.path.exists(os.path.join(path, ".git")):
        # Attempt to create a "clean" version, but fall back to a "dirty"
        # one if need be.
        version = buck_version.get_clean_buck_version(path)
        timestamp = -1
        if version is None:
            version = buck_version.get_dirty_buck_version(path)
        else:
            timestamp = buck_version.get_git_revision_timestamp(path)
        dirty = buck_version.is_dirty(path)
    else:
        # We're building outside a git repo. Check for the special
        # .buckrelease file created by the release process.
        try:
            with open(os.path.join(path, ".buckrelease")) as f:
                timestamp = int(os.fstat(f.fileno()).st_mtime)
                version = f.read().strip()
        except IOError as e:
            if e.errno == errno.ENOENT:
                # No .buckrelease file. Do the best that we can.
                version = "(unknown version)"
                timestamp = int(time.time())
            else:
                raise e
        dirty = False

    json.dump(
        {
            "version": version,
            "timestamp": timestamp,
            "is_dirty": dirty
        },
        sys.stdout,
        sort_keys=True,
        indent=2,
    )
Esempio n. 4
0
def main(argv):
    parser = argparse.ArgumentParser()
    parser.add_argument("--release-version", help="The buck release version")
    parser.add_argument(
        "--release-timestamp", help="The unix timestamp when the release happened"
    )
    args = parser.parse_args(argv[1:])
    if bool(args.release_version) != bool(args.release_timestamp):
        print(
            "--release-version and --release-timestamp must either both be "
            "set, or neither can be set"
        )
        sys.exit(1)

    # Locate the root of the buck repo.  We'll need to be there to
    # generate the buck version UID.
    path = os.getcwd()
    while not os.path.exists(os.path.join(path, ".buckconfig")):
        path = os.path.dirname(path)

    if args.release_version:
        version = args.release_version
        timestamp = args.release_timestamp
        dirty = False
    elif os.path.exists(os.path.join(path, ".git")):
        # Attempt to create a "clean" version, but fall back to a "dirty"
        # one if need be.
        version = buck_version.get_clean_buck_version(path)
        timestamp = -1
        if version is None:
            version = buck_version.get_dirty_buck_version(path)
        else:
            timestamp = buck_version.get_git_revision_timestamp(path)
        dirty = buck_version.is_dirty(path)
    else:
        # We're building outside a git repo. Check for the special
        # .buckrelease file created by the release process.
        try:
            with open(os.path.join(path, ".buckrelease")) as f:
                timestamp = int(os.fstat(f.fileno()).st_mtime)
                version = f.read().strip()
        except IOError as e:
            if e.errno == errno.ENOENT:
                # No .buckrelease file. Do the best that we can.
                version = "(unknown version)"
                timestamp = int(time.time())
            else:
                raise e
        dirty = False

    json.dump(
        {"version": version, "timestamp": timestamp, "is_dirty": dirty},
        sys.stdout,
        sort_keys=True,
        indent=2,
    )
Esempio n. 5
0
def main(argv):

    # Locate the root of the buck repo.  We'll need to be there to
    # generate the buck version UID.
    path = os.getcwd()
    while not os.path.exists(os.path.join(path, '.buckconfig')):
        path = os.path.dirname(path)

    # Attempt to create a "clean" version, but fall back to a "dirty"
    # one if need be.
    version = buck_version.get_clean_buck_version(path)
    timestamp = -1
    if version is None:
        version = buck_version.get_dirty_buck_version(path)
    else:
        timestamp = buck_version.get_git_revision_timestamp(path)

    json.dump(
        {'version': version, 'timestamp': timestamp},
        sys.stdout,
        sort_keys=True,
        indent=2)
Esempio n. 6
0
def main(argv):

    # Locate the root of the buck repo.  We'll need to be there to
    # generate the buck version UID.
    path = os.getcwd()
    while not os.path.exists(os.path.join(path, '.buckconfig')):
        path = os.path.dirname(path)

    # Attempt to create a "clean" version, but fall back to a "dirty"
    # one if need be.
    version = buck_version.get_clean_buck_version(path)
    timestamp = -1
    if version is None:
        version = buck_version.get_dirty_buck_version(path)
    else:
        timestamp = buck_version.get_git_revision_timestamp(path)

    json.dump({
        'version': version,
        'timestamp': timestamp
    },
              sys.stdout,
              sort_keys=True,
              indent=2)
Esempio n. 7
0
 def _get_git_commit_timestamp(self):
     if self._is_buck_repo_dirty_override or not self._is_git:
         return -1
     return buck_version.get_git_revision_timestamp(self._buck_dir)
Esempio n. 8
0
 def _get_git_commit_timestamp(self):
     if self._is_buck_repo_dirty_override or not self._is_git:
         return -1
     return buck_version.get_git_revision_timestamp(self._buck_dir)