Skip to content

Commit fa141f5

Browse files
committed
Improve verbosity for -c and only guess update information if GITHUB_TOKEN is set
1 parent c2f4a37 commit fa141f5

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

appimagetool.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ int sfs_mksquashfs(char *source, char *destination, int offset) {
199199
/* Validate desktop file using desktop-file-validate on the $PATH
200200
* execlp(), execvp(), and execvpe() search on the $PATH */
201201
int validate_desktop_file(char *file) {
202-
int number, statval;
202+
int statval;
203203
int child_pid;
204204
child_pid = fork();
205205
if(child_pid == -1)
@@ -433,12 +433,14 @@ main (int argc, char *argv[])
433433
* TRAVIS_REPO_SLUG: The slug (in form: owner_name/repo_name) of the repository currently being built.
434434
* TRAVIS_TAG: If the current build is for a git tag, this variable is set to the tag’s name.
435435
* We cannot use g_environ_getenv (g_get_environ() since it is too new for CentOS 6 */
436-
char* travis_commit;
437-
travis_commit = getenv("TRAVIS_COMMIT");
436+
// char* travis_commit;
437+
// travis_commit = getenv("TRAVIS_COMMIT");
438438
char* travis_repo_slug;
439439
travis_repo_slug = getenv("TRAVIS_REPO_SLUG");
440440
char* travis_tag;
441441
travis_tag = getenv("TRAVIS_TAG");
442+
char* travis_pull_request;
443+
travis_pull_request = getenv("TRAVIS_PULL_REQUEST");
442444
/* https://github.com/probonopd/uploadtool */
443445
char* github_token;
444446
github_token = getenv("GITHUB_TOKEN");
@@ -726,14 +728,24 @@ main (int argc, char *argv[])
726728

727729
/* If the user has not provided update information but we know this is a Travis CI build,
728730
* then fill in update information based on TRAVIS_REPO_SLUG */
729-
if(guessupdateinformation != NULL){
730-
if(travis_repo_slug != NULL){
731+
if(guessupdateinformation){
732+
if(!travis_repo_slug){
733+
printf("Cannot guess update information since $TRAVIS_REPO_SLUG is missing\n");
734+
} else if(!github_token) {
735+
printf("Will not guess update information since $GITHUB_TOKEN is missing,\n");
736+
if(0 != strcmp(travis_pull_request, "false")){
737+
printf("please set it in the Travis CI Repository Settings for this project.\n");
738+
printf("You can get one from https://github.com/settings/tokens\n");
739+
} else {
740+
printf(", which is expected since this is a pull request\n");
741+
}
742+
} else {
731743
gchar *zsyncmake_path = g_find_program_in_path ("zsyncmake");
732744
if(zsyncmake_path){
733745
char buf[1024];
734746
gchar **parts = g_strsplit (travis_repo_slug, "/", 2);
735747
/* https://github.com/AppImage/AppImageSpec/blob/master/draft.md#github-releases
736-
* gh-releases-zsync|probono|AppImages|latest|Subsurface-*-x86_64.AppImage.zsync */
748+
* gh-releases-zsync|probono|AppImages|latest|Subsurface*-x86_64.AppImage.zsync */
737749
gchar *channel = "continuous";
738750
if(travis_tag != NULL){
739751
if((strcmp(travis_tag, "") != 0) && (strcmp(travis_tag, "continuous") != 0)) {
@@ -747,8 +759,6 @@ main (int argc, char *argv[])
747759
} else {
748760
printf("Will not guess update information since zsyncmake is missing\n");
749761
}
750-
} else {
751-
printf("Cannot guess update information since $TRAVIS_REPO_SLUG is missing\n");
752762
}
753763
}
754764

0 commit comments

Comments
 (0)