Create project command

This still leaves a larger possibility for collision. Since this sha is used only internally and will not be user-visible it doesn’t make sense to abbreviate the sha.

Is there a particular benefit to abbreviating it here?

Further reading: http://blog.cuviper.com/2013/11/10/how-short-can-git-abbreviate/


From: Fatme [mailto:notifications@github.com]
Sent: Tuesday, July 8, 2014 12:29 PM
To: NativeScript/nativescript-cli
Cc: Stefan Dragnev
Subject: Re: [nativescript-cli] Create project command (#2)


In lib/services/project-templates-service.ts:

> +            }).future<string>()();

> +     }

> +

> +     private getLatestMasterCommitSha(): IFuture<string> {

> +            return (() => {

> +                    try {

> +                            var refs = JSON.parse(this.$httpClient.httpRequest(ProjectTemplatesService.GITHUB_DEFAULT_TEMPLATE_REFS_ENDPOINT).wait().body);

> +                    } catch(error) {

> +                            this.$logger.debug(error);

> +                            this.$errors.fail(ProjectTemplatesService.DEFAULT_TEMPLATE_PULL_FAILED_MESSAGE);

> +                    }

> +

> +                    var masterRef = _.find(refs, (ref: any) => { return ref.ref == ProjectTemplatesService.GITHUB_MASTER_REF_NAME});

> +                    var masterRefSha = masterRef.object.sha;

> +

> +                    return masterRefSha.toString().substr(0, 7);

We don't need the entire sha. The package that comes from git is named for example telerik-nativescript-sample-cuteness-9bad7a5, so we need only the first 7 chars :)

—
Reply to this email directly or view it on GitHub<https://github.com/NativeScript/nativescript-cli/pull/2/files#r14644098>.