Skip to content

Commit ece4bb5

Browse files
committed
Revert a9f2597
Revert a9f2597 to see if this has an impact on #934
1 parent 0b28a14 commit ece4bb5

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

src/appimagetool.c

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static gboolean sign = FALSE;
7979
static gboolean no_appstream = FALSE;
8080
gchar **remaining_args = NULL;
8181
gchar *updateinformation = NULL;
82-
static gboolean guess_update_information = FALSE;
82+
static gboolean guessupdateinformation = FALSE;
8383
gchar *bintray_user = NULL;
8484
gchar *bintray_repo = NULL;
8585
gchar *sqfs_comp = "gzip";
@@ -464,7 +464,7 @@ static GOptionEntry entries[] =
464464
{
465465
{ "list", 'l', 0, G_OPTION_ARG_NONE, &list, "List files in SOURCE AppImage", NULL },
466466
{ "updateinformation", 'u', 0, G_OPTION_ARG_STRING, &updateinformation, "Embed update information STRING; if zsyncmake is installed, generate zsync file", NULL },
467-
{ "guess", 'g', 0, G_OPTION_ARG_NONE, &guess_update_information, "Guess update information based on Travis CI or GitLab environment variables", NULL },
467+
{ "guess", 'g', 0, G_OPTION_ARG_NONE, &guessupdateinformation, "Guess update information based on Travis CI or GitLab environment variables", NULL },
468468
{ "bintray-user", 0, 0, G_OPTION_ARG_STRING, &bintray_user, "Bintray user name", NULL },
469469
{ "bintray-repo", 0, 0, G_OPTION_ARG_STRING, &bintray_repo, "Bintray repository", NULL },
470470
{ "version", 0, 0, G_OPTION_ARG_NONE, &showVersionOnly, "Show version number", NULL },
@@ -559,11 +559,12 @@ main (int argc, char *argv[])
559559
* TODO: Might also want to somehow make use of
560560
* git rev-parse --abbrev-ref HEAD
561561
* git log -1 --format=%ci */
562-
gchar* version_env = getenv("VERSION");
563-
564-
if (guess_update_information){
565-
if (g_find_program_in_path("git")) {
562+
gchar *version_env; // In which cases do we need to malloc() here?
563+
version_env = getenv("VERSION");
564+
if(guessupdateinformation){
565+
if(g_find_program_in_path ("git")) {
566566
if (version_env == NULL) {
567+
<<<<<<< HEAD
567568
GError* error = NULL;
568569
gchar* out = NULL;
569570

@@ -584,6 +585,24 @@ main (int argc, char *argv[])
584585
g_printerr(" %s\n", version_env);
585586
g_printerr(" Please set the $VERSION environment variable if this is not intended\n");
586587
}
588+
=======
589+
GError *error = NULL;
590+
gchar *out = NULL;
591+
GString *command_line = g_string_new("git");
592+
g_string_append_printf(command_line, " rev-parse --short HEAD");
593+
int ret = g_spawn_command_line_sync(command_line->str, &out, NULL, NULL, &error);
594+
g_assert_no_error(error);
595+
if (ret) {
596+
version_env = g_strstrip(out);
597+
} else {
598+
g_print("Failed to run 'git rev-parse --short HEAD'");
599+
}
600+
g_string_free(command_line, true);
601+
if (version_env != NULL) {
602+
g_print("NOTE: Using the output of 'git rev-parse --short HEAD' as the version:\n");
603+
g_print(" %s\n", version_env);
604+
g_print(" Please set the $VERSION environment variable if this is not intended\n");
605+
>>>>>>> parent of a9f2597... Increase robustness of git commit version guessing
587606
}
588607
}
589608
}
@@ -861,7 +880,7 @@ main (int argc, char *argv[])
861880

862881
/* If the user has not provided update information but we know this is a Travis CI build,
863882
* then fill in update information based on TRAVIS_REPO_SLUG */
864-
if(guess_update_information){
883+
if(guessupdateinformation){
865884
if(travis_repo_slug){
866885
if(!github_token) {
867886
printf("Will not guess update information since $GITHUB_TOKEN is missing,\n");

0 commit comments

Comments
 (0)